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
11
votes
4 answers

Can jQuery.data cause a memory leak?

Would the following piece of code create a memory leak. According to the jQuery documentation use of the data function avoids memory leaks. It would be useful to confirm whether the following is safe. var MyClass = function(el) { // Store…
Lea Hayes
  • 62,536
  • 16
  • 62
  • 111
11
votes
2 answers

Am I allowed to make circular references with constants structs?

Am I allowed to do this in C99? typedef struct dlNode { dlNode* next, prev; void* datum; } dlNode; const static dlNode head={ .next = &tail, .prev = NULL, .datum = NULL }; const static dlNode tail={ .next = NULL, .prev…
Mr. Minty Fresh
  • 229
  • 1
  • 6
11
votes
1 answer

Compare objects on equality in PHP

Specifics First, the definition of "equality" in my case is - that objects are equal when they have same structure and values for that structure. However, they may be not same instance, or properties may be not in same "order" (I mean, as they were…
Alma Do
  • 37,009
  • 9
  • 76
  • 105
11
votes
1 answer

Why Swift does not dispose circular references (strong reference cycles) automatically

sorry if it's a silly question. I just started learning swift. I mainly use php for my daily job. Apple Store's Swift textbook uses the following example (i modified it into a shorter version) to demonstrate the usage of weak reference: class Person…
Peter Li
  • 789
  • 6
  • 13
10
votes
3 answers

Nesting Views within Views in backbone js

I'm working with backbone.js building some complex view relationships, and I'm wondering if there are any problems from a javascript performance standpoint of doing something that looks like this: var viewOne = Backbone.View.extend({ …
tgriesser
  • 2,808
  • 1
  • 22
  • 22
10
votes
2 answers

Symfony serializer - set circular reference global

Is there any way to set the circular reference limit in the serializer component of Symfony (not JMSSerializer) with any config or something like that? I have a REST Application with FOSRestBundle and some Entities that contain other entities which…
10
votes
2 answers

Test if variable contains circular references

How do you test a variable for circular references? I am using PHP's var_export() function with the return string argument set to true. I found that Warning: var_export does not handle circular references and was wondering if anyone knew of a way to…
km6zla
  • 4,787
  • 2
  • 29
  • 51
10
votes
1 answer

How jQuery data() breaks circular reference

I have read an why it's better and how it's implemented. But what i don't really understand is how does it break the circular reference?. how does it break the reference circle? $(div1).data('item', div2); $(div2).data('item', div1); like example,…
Joseph
  • 117,725
  • 30
  • 181
  • 234
9
votes
2 answers

How to declare an immutable graph with circular references?

I want to declare a graph of all states where the edges represent contiguous states. I think what I am trying to do might be called "tying the knot" (not sure about that though). It's not working like I expected, and I have a couple of…
Josh Buedel
  • 1,853
  • 16
  • 41
9
votes
1 answer

Proper care and safety when dealing with traceback objects from sys.exc_info()

I'm aware that the sys.exc_info documentation says to take care when dealing with traceback objects, but am still uncertain of how safe or unsafe some cases are. Additionally, the documentation says "Warning: Don't do this!", followed immediately…
Richard Levasseur
  • 14,562
  • 6
  • 50
  • 63
9
votes
1 answer

Circular Reference with Nested Nav Graphs

I have a complex navigation structure, I go from one nav graph then based on some logic, decide which nav graph to go to there. However both the nav graphs share 3 other nav graphs. See image below Currently I get a circular reference error if I…
9
votes
4 answers

How to perform a sorting according to rules but with repetition of items to solve circular references?

To explain in a clearer way my question I will start by explaining the real-life case I am facing. I am building a physical panel with many words on it that can be selectively lit, in order to compose sentences. This is my situation: I know all the…
mac
  • 42,153
  • 26
  • 121
  • 131
9
votes
5 answers

How to solve circular reference in json serializer caused by Many TO Many hibernate bidirectional mapping?

I am trying to serialize POJO to JSON but stuck in circular reference problem. I know how to handle one to many and reverse relationships using the @JsonBackReference and @JsonManagedReference. My problem is with bidirectional many-to-many…
M.Rather
  • 101
  • 2
  • 3
9
votes
1 answer

scala: circular reference while creating object?

I accidentally ran into a situation like this (the example is simplified to isolate the problem): abstract class Element(val other: Element) case object First extends Element(Second) case object Second extends Element(First) object Main { def…
Vilius Normantas
  • 3,708
  • 6
  • 25
  • 38
9
votes
1 answer

Pickle/dill cannot handle circular references if __hash__ is overridden

Consider the following MWE: #import dill as pickle # Dill exhibits similar behavior import pickle class B: def __init__(self): self.links = set() class A: def __init__(self, base: B): self.base = base …
Pavel Kirienko
  • 1,162
  • 1
  • 15
  • 31