Questions tagged [self-reference]

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Useful Links:

Stanford Encyclopedia 'Self Reference' Entry

Related Tags:

596 questions
2
votes
5 answers

A better idiom for referring to base classes from derived classes?

Suppose I have a template class A : class_with_long_name, anotherclass_with_long_name { ...…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
2
votes
1 answer

Function Type which Returns Itself

I'm trying to write a very minimal state machine in C++. I'd like the states to be methods of the machine's class, and each state, when run, should return the new state to move to. Naturally, I'm using a few typedef's to help out. template
Silvio Mayolo
  • 62,821
  • 6
  • 74
  • 116
2
votes
2 answers

How to prevent deep recursive queries with entities consisting of entities of the same type? [Cool example inside]

No worries! It looks more complex than it actually is! Just get down to the drinks! TLDR-version: How to efficiently query and update entities having relationships to other entities? Here's an interesting data modeling scenario with two tables that…
2
votes
5 answers

How to create an interface with abstract methods that reference self-type in java

I'm sure this has been answered 100 times but I'm not sure what to search for. I want to create an interface with an abstract method that enforces a parameter of self-type of the class that implements it. Whew, that's a mouthful. For example, I have…
Michael
  • 318
  • 3
  • 14
2
votes
5 answers

Mysql Query Incorporating Self Referential Join

Say I have four tables: ------------- features -------------- id: int name: varchar ------------------------------------- -------- feature_categories --------- feature_id: int category_id: int ------------------------------------- -----------…
mark
  • 10,316
  • 6
  • 37
  • 58
2
votes
2 answers

TypeScript: self-referencing return type for methods in inheriting classes

Disclaimer: I'm finding it hard to summarise the problem in the title of the question, so if you have better suggestions, please let me know in the comments. Let's take the following simplified TypeScript class: class Model { save():Model { //…
Merott
  • 7,189
  • 6
  • 40
  • 52
2
votes
2 answers

C++ - Constructors and self-referencing classes

Before I begin, I would just like to say thank you to anyone who attempts to help me. So now, to the problem at hand. I have a Vector class, and I need to have a static object called zero which is a Vector with x = 0, y = 0, and z = 0 Here is my…
Ben
  • 61
  • 1
  • 9
2
votes
1 answer

Self Referencing on a separate table - BoM in Laravel

I'm curious if there's an easy way of implementing a bill of materials (assemblies) type recursive system using eloquent? Here are the two table structures I'm working with: inventory table: +----+------------+-------------+ | id | name |…
2
votes
3 answers

Optimizaion of calculating how many data.frame record timestamps appear in a one second window from every record timestamp in that data.frame

I have an R data.frame with a number of columns, one of which contains POSIXct timestamp records. I want to add a column to the data.frame that, for each row, contains the number of records that have a timestamp between that row's timestamp and one…
2
votes
1 answer

Crystal reports - using value of current object in formula

I am creating a Crystal Report using c# and I have to replicate a simple formula in 320 different parameters but always with the same condition as follows: if ({Precios.AhorroE1}[1] = '-') then crGreen else ( crRed ) Each object has a different…
Miquel Coll
  • 759
  • 15
  • 49
2
votes
3 answers

Java Self Reference with Inhertiance

I understand why this code below doesn't work. That's because convolusion will call Base, not Derived. This code is soooo simple, and have self-referencing. I extended 'self-referencing class' and I stucked with that problem. class Base { public…
Phryxia
  • 139
  • 9
2
votes
0 answers

Gson deserialize list of self nested elements. Error: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING

I am trying to deserialize JSON object. It is quite complecated cause, the json i actual a list of objects that are self related (one element can have many children) I use method: public List toObject(String jsonObject) { Gson…
masterdany88
  • 5,041
  • 11
  • 58
  • 132
2
votes
2 answers

Best practice for recursive class

Problem: I want to build a class for a custom dice. But it should also provide the following: Every side can contain an other dice The number of sides should be dynamically expandable, but must at least contain one Logically the dice need to have…
Firen
  • 272
  • 1
  • 13
2
votes
1 answer

dart: get object within anonymous function

I want to access the object itself within a listen-callback. SomeObject o = new SomeObject() ..onEvent.listen((Event ev){ //now I want to access Object o. }); It works if I call onEvent.listen after o is created, but I want to…
NaN
  • 3,501
  • 8
  • 44
  • 77
2
votes
1 answer

Self referential relationship including a relationship attribute

Situation I have the Self-Referential Many-to-Many Relationship (almost identical to the sqlalchemy manual entry of the same heading). This relationship is governed by the table entity_weights. This code works! Question How do I include an attribute…
Justin Solms
  • 695
  • 1
  • 6
  • 14