Microsoft
Software
Hardware
Network
Question : 2 levels treeMap
This a continuation to question
http://www.experts-exchan
ge.com/Pro
gramming/L
anguages/J
ava/Q_2634
6400.html
What I need to do now,
I need to traverse a tree and store some values (if some conditions are true) in another structure
The value is structured as follow:
Node1:
Element1{ name1, value1}
Element2{name2, value2}
…
Node2:
Element1{ name1, value1}
Element2{name2, value2}
…
Node3
SubNode3:
Element1{ name1, value1}
Element2{name2, value2}
…
So the depth of the tree is no more than 2 (element under node or element under subnode under node)
What is the best structure to hold that ? some combination of map and tree would be very useful , I guess a TreeMap ?
Is there a sample code on how to do that ? going two levels down ?
Thanks
Answer : 2 levels treeMap
i guess you just need to have nested treemap only.
Also Create an element class with 2 attributes: key and value
something like
TreeMap parentTM = new TreeMap();
TreeMap childTM1 = new TreeMap();
TreeMap childTM2 = new TreeMap();
Element elem1 = new Element(key, value);
...
// Put elements to the map
childTM1.put("1", elem1 );
childTM1.put("2", elem2 );
childTM2.put("1", elem1 );
childTM2.put("2", elem2 );
parentTM.put("1", childTM1 );
parentTM.put("2", childTM2 );
Random Solutions
View Composer agent initialization state error (2): Failed to redirect profiles directory (waited 0 seconds)
RHCE Exam
Cross-forest trust: The domain controllers required to find the selected objects in the following domains are not available
Deleted Active Directory Administrator account
Group and ungroup a password-protected sheet?
Outlook 2007 stuck Offline
Error"Cannot connect to Citrix Server. Proxy detection failure: Improper auto-configuration URL"
Windows 7 Enterprise vs Ultimate?
convert c++ delegate parameters for managed code
Inexpensive IR Transceiver Alternatives?