J
Joona I Palaste
Trees don't fit in the Java Collections framework, as they require the
objects themselves to know about the collection they are in, namely what
their children are.
In all other collections, the order in which the objects are is either
irrelevant (like in sets) or canonical (like in lists) but in trees,
there may be multiple orders chosen by the user of the collection.
What are possible solutions to this? Making the objects inherit a
"TreeNode" interface won't work as it will prevent the same object from
being in several trees simultaneously. Perhaps using wrapper objects as
the nodes, with references pointing to the actual objects?
--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A bee could, in effect, gather its junk. Llamas (no poor quadripeds) tune
and vow excitedly zooming."
- JIPsoft
objects themselves to know about the collection they are in, namely what
their children are.
In all other collections, the order in which the objects are is either
irrelevant (like in sets) or canonical (like in lists) but in trees,
there may be multiple orders chosen by the user of the collection.
What are possible solutions to this? Making the objects inherit a
"TreeNode" interface won't work as it will prevent the same object from
being in several trees simultaneously. Perhaps using wrapper objects as
the nodes, with references pointing to the actual objects?
--
/-- Joona Palaste ([email protected]) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"A bee could, in effect, gather its junk. Llamas (no poor quadripeds) tune
and vow excitedly zooming."
- JIPsoft