The Artima Developer Community
Sponsored Link

Java Answers Forum
add one Treemap to another, etc...

2 replies on 1 page. Most recent reply: Aug 9, 2005 1:29 PM by Neil

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
mike

Posts: 2
Nickname: poirot
Registered: Jul, 2005

add one Treemap to another, etc... Posted: Jul 6, 2005 12:38 PM
Reply to this message Reply
Advertisement
How do I add one tree map object to a 2nd Treemap object
& then confirm a new entry (or the new entrys) are/is added thereby incrementing the count of items contained
in the treemap object?

I have a treemap named:
"TreeMap hmIC = new TreeMap().
& a 2nd treemap object named "hmID".
& a 3rd treemap object named "bothmap".

I want to have "bothmap" contain items in
"hmIC" & "hmID".

I've done this:

bothmap = hmIC; <- so bothmap shoud now equal hmIC

Then I put bothmap in a loop to add more objects
(ultimately to make bothmap have what is in the
other two TreeMaps (since I did not know another
way to simply add the two TreeMaps together):

while ( blah blah foo...) {
System.out.println("bothmap.size()="+bothmap.size());
bothmap.put( ii1, result);
System.out.println("bothmap.size()="+bothmap.size());
}

I surround the "put" with "bothmap.size()"inside
print statements before & after the "while".

The value given never changes as though nothing
else is getting inserted into bothmap. I know
something in in

is there a better way to this? And shouldn't
"bothmap.size()" give me the number of items
contained in bothmap ?


mike

Posts: 2
Nickname: poirot
Registered: Jul, 2005

Re: add one Treemap to another, etc... Posted: Jul 6, 2005 10:48 PM
Reply to this message Reply
hmmmm.

Neil

Posts: 1
Nickname: nero
Registered: Aug, 2005

Re: add one Treemap to another, etc... Posted: Aug 9, 2005 1:29 PM
Reply to this message Reply
I'm also new to Java programming and currently working on an assignment using Treemaps.

I maybe wrong, but I think you have to nest your Treemaps.
You create your first Treemap and then call it up in your second Treemap.

I'm still trying to work it out, but having difficulty finding anything on the Internet describing nested Treemaps - anyone know any good links?

Flat View: This topic has 2 replies on 1 page
Topic: visibility issue Previous Topic   Next Topic Topic: please help me on this question

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use