Questions tagged [circular-reference]

A circular reference is a series of references where the last object references the first, resulting in a closed loop.

A circular reference is a series of references where the last object references the first, resulting in a closed loop.

Circular references can appear in computer programming when one piece of code requires the result from another, but that code needs the result from the first.

Information is taken from Wikipedia, more information available there.

758 questions
5
votes
5 answers

Is there any usage of self-referential lists or circular reference in list, eg. appending a list to itself

So if I have a list a and append a to it, I will get a list that contains it own reference. >>> a = [1,2] >>> a.append(a) >>> a [1, 2, [...]] >>> a[-1][-1][-1] [1, 2, [...]] And this basically results in seemingly infinite recursions. And not only…
Sayandip Dutta
  • 15,602
  • 4
  • 23
  • 52
5
votes
4 answers

What is the scale of PHP's circular reference problem and should I worry about it?

If I am using a tree structure of nodes similar to the code below, do I have to worry about the circular reference? I have read that PHP uses a memory allocation mechanism which can make life very hard for the garbage collector when there are…
meouw
  • 41,754
  • 10
  • 52
  • 69
5
votes
2 answers

How to use ImmutableJS Map with TypeScript

I have a tree structure that looks something like this: interface TreeData { id : number; text : string; children : TreeData[]; } I want to wrap this up into an Immutable Map but since I'm using TypeScript, I would like some type safety…
Marek Krzeminski
  • 1,308
  • 3
  • 15
  • 40
5
votes
1 answer

Any tool to check circular dependency in a JSON schema

I am using JSON file and validated it on Swagger 2.0 Parser and validator it validates it but give error of circular reference, is there any free tool or website to detect the position of circular reference in a file.
Syed Uzair Uddin
  • 3,296
  • 7
  • 31
  • 47
5
votes
3 answers

Circular Reference with python lists

Can someone explain this? >>> x = x[0] = [0] >>> x [[...]] >>> x is x[0] True >>> x[0][0][0][0][0][0][0] [[...]] >>> x in x True what is [...]?
Jim Simons
  • 53
  • 3
5
votes
1 answer

Elixir, no circular reference possible?

I am learning Elixir, up to chapter 7 PragProg book, and after thinking about the immutability and other items, I was thinking it was not generally possible to create a circular reference in the Elixir Maps/Tuples/Lists, etc.. Where A -> B -> C ->…
Daniel
  • 7,006
  • 7
  • 43
  • 49
5
votes
2 answers

Delphi: better design to avoid circular unit reference?

I have a triangular mesh structure in Delphi 10. For performance reasons I store the data of the mesh's vertices, triangle faces, etc. in descendants of TList. I let the TLists do the calculations for every member of the list. For these calculations…
user3384674
  • 759
  • 8
  • 28
5
votes
0 answers

Jackson @jsonidentityinfo change the original data structure

I have below 2 classes with circular reference,I didn't put getters and setters for convenience @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "i") public class A{ int i; B b1; B…
Shuai
  • 51
  • 3
5
votes
4 answers

Circular references with vals in Kotlin

In Kotlin, say I have data class A (val f: B) and data class B (val f: A). I want to initialize local var a: A and var b: B such that a.f is b and b.f is a. A.f and B.f must remain vals. Is this circular instantiation possible? data class A(val f:…
sargunv
  • 2,548
  • 1
  • 13
  • 11
5
votes
1 answer

Ada: how to solve "Circular Unit Dependency"?

Suppose I have two records: Person and Animal. Each record is in a separate package. Package persons: with animals; use animals; package persons is type person is record ... animalref: animalPOINTER; ... end record; …
LamportA
  • 53
  • 1
  • 5
5
votes
1 answer

Avoid Circular References in Symfony2's Dependency Injection?

I am a big fan of dependency injection, but something bothers me and I was wondering whether someone could give me an explanation: It is not possible to create two services that depends on each other, because we will get a "Circular Reference"…
Vincent Pazeller
  • 1,448
  • 18
  • 28
5
votes
0 answers

JPA Bidirectional relationship - infinite loop / circular reference

I have a bidirectional relationship @Entity @Table(name = "facility") public class Facility implements Serializable { @Id @GeneratedValue private Long id; @OneToMany(mappedBy = "facility") private Set
5
votes
1 answer

Hierarchical object and AutoFixture

I have implemented a class for storing tags, the tag collection must be hierachical, and so my class is: public class Tag { public int Id { get; set; } public int Description { get; set; } public Tag ParentTag { get; set; } // ……
gt.guybrush
  • 1,320
  • 3
  • 19
  • 48
5
votes
5 answers

c# : Utility to find circular references / compile in correct order?

doers anyone know of a good utility or program to interrogate a solution or a directory for all projects and tell you where circular references are and possible compile in order.. I remember see one a while ago but i can't find it anywhere..
mark smith
  • 20,637
  • 47
  • 135
  • 187
5
votes
4 answers

INSERT in TABLES with circular references SQL

I have 2 tables: Empleados(**numEmpl**, nombre, apellido, sexo, telefono, salario, numDept) Departamentos(**numDept**, nombreDept, numDirect) In departamentos: numEmpl is primary key numDept is foreign key reference to Departamentos(numDept). In…
carlos
  • 139
  • 1
  • 14