rune icon indicating copy to clipboard operation
rune copied to clipboard

Doubly linked relation?

Open jgarvin opened this issue 2 years ago • 1 comments

In the class example in the README, the Human class adds self to mother and father. However it does not add mother and father anywhere into self, which is what I would expect with "DoublyLinked." What does it mean?

jgarvin avatar Nov 27 '22 17:11 jgarvin

mother.appendMotheredHuman(self) adds self to the doubly-linked list of mothered children of mother. This also sets a back pointer from self to mother. That way, we later are destroyed, our destructor can use that back pointer to find our mother and remove us from her list of mothered children. We can access our mother with self.motherHuman, and our father with self.fatheredHuman

Does that make sense? I'm not used to describing doubly-linked lists and back-pointers. I've been using them for decades.

waywardgeek avatar Nov 29 '22 20:11 waywardgeek