Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Java shit question

Name: Anonymous 2013-04-29 9:58

Hi

I have a structure like that

AtributeList
   |
   +-- Atribute
   +-- Atribute
   +-- Atribute

That is, an object that handles many Atribute inside. But i made it so Atribute can also contain another AtributeList.

What's a good way of checking for circular references (That is, one atribute contains an AtributeList that is its ancestor), besides, of course, brute force checking of each ancestor.

Name: Anonymous 2013-04-29 10:08

Name: Anonymous 2013-04-29 10:26

disregard >>2, what's wrong with DFS?

Name: Anonymous 2013-04-29 10:42

>>3
I don't know. But maybe if i keep a table of some kind? Just to avoid to check everything when i add an atribute to an AtributeList?

Name: Anonymous 2013-04-29 12:14

What is this and how do you plan on using it? Why/How would you ever get cyclical references? How are these references bad for you?

Name: Anonymous 2013-04-29 14:32

>>5
I will serialize it to xml so it can't be circular.

I will add AtributeList to at least 4 different objects. Each object will have one and only one instance of AttributeList.

I don't see any use case where this can happen, but i still have tests that checks for circular references, as it is on the requirements for AttributeList and Attribute.

Name: Anonymous 2013-04-29 14:49

>>4
I don't see a way out of having to check down the chain to see if you're circular or not. Or up the chain, whichever you prefer.

Don't change these.
Name: Email:
Entire Thread Thread List