| Author |
delete values from a hastable
|
ben riches
Ranch Hand
Joined: Nov 08, 2002
Posts: 126
|
|
hello everyone i hope someone can help i have the code below which tests if any strings are the same to print them out plus there key values but now i want to able to delete the values and the key names that have already been used can anyone help please thanks loftty [ December 09, 2002: Message edited by: Michael Ernest ]
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
It you want to remove values from the Hashtable while you're looping through it, use an Iterator rather than an Enumeration (as shown in my other post), and use the remove() method of the Iterator. Otherwise you can use the remove(Object) method of Hashtable, where the argument is the key value to be removed. But don't do this while you're looping through the Hashtable - it confuses things. [ December 09, 2002: Message edited by: Jim Yingst ]
|
"I'm not back." - Bill Harding, Twister
|
 |
Ted Striker
Greenhorn
Joined: Dec 08, 2002
Posts: 7
|
|
Jim, I posted a HashMap question below and your response to Ben's post has my attention. I want to take two hashmaps, iterate through each one and remove the hashmap elements that do not match keys. I was recommended an interfact (Coparable) solution but I am trying to make it simpler. How can I iterate through two hashmaps simultaneously while removing elements that don't match? You mention not removing elements while looping. I don't understand. Please see my post re: data structures. Ted
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
I replied here.
|
 |
 |
|
|
subject: delete values from a hastable
|
|
|