Results 1 to 6 of 6
Thread: hashTable restructuring
-
hashTable restructuring
i have a hashTable<Integer, noteHeader>
the noteHeader class is:
the keys are sequential numbers.Java Code:public class noteHeader { public String displayText; public String noteText; public noteHeader(String text1, String text2){ this.displayText = text1; this.noteText = text2; } }
my question is, when i remove an item, how can i modify all of the keys after the removed item so the hashTable keys are still sequential numbers?
-
Re: hashTable restructuring
You shouldn't modify the keys of a HashMap or a HashTable.
-
Re: hashTable restructuring
it's the only way. i need to remove an element from the hashTable when a jList item is removed. the keys correspond to the jList list indices + not modifying the hashTable is not an option.
-
Re: hashTable restructuring
It's always an option, and you've yet to convince me otherwise yet (I'm stubborn). Why are you using a HashTable to begin with since this has been largely superseded by HashMap? Why not simply an ArrayList if you need the indices to re-align so that it remains monotonically increasing and without gaps?
- 06-29-2012, 11:48 PM #5
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,606
- Rep Power
- 5
Re: hashTable restructuring
Why are you using a HashTable / Map at all? Why not a List?
-
Similar Threads
-
Hashtable question. Getting info from a hashtable
By sindrem in forum New To JavaReplies: 4Last Post: 01-19-2012, 05:00 PM -
hashtable
By vijayabaskar in forum Java ServletReplies: 0Last Post: 04-06-2009, 08:20 AM -
hashtable
By vijayabaskar in forum Advanced JavaReplies: 2Last Post: 04-06-2009, 08:05 AM -
Hashtable
By angelicsign in forum New To JavaReplies: 6Last Post: 02-05-2009, 04:30 PM -
Hashtable example
By Java Tip in forum Java TipReplies: 0Last Post: 02-15-2008, 08:43 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks