Hello,
I populate a hashtable with recordID's in a "For i=0 to n" loop. Some
recordID's are duplicate but for different rows (recordID is not a key field
in this scenario). I use the value of "i" in the For loop as the key in the
hashtable (which is actually the currencyManager counter).
Originally, I was using the recordID as the key and "i" as the value. So if
I user needed to go to recordID = 12345, I just retrieve the corresponding
value for that key and make currencyManager go to that value. But since I
now have duplicate RecordID's I can't use that as the key. So I switched it
around where the value of "i" is now the key and the RecordID is the value.
I experimented with the DictionaryEntry object to retrieve the key based on
a value, but I have to loop through the entire hashtable to locate the
desired DictionaryEntry. Is there a way to go to the desired row in the
Hashtable without having to loop?
Thanks,
Rich
housebuyer@gmail.com - 18 May 2006 00:43 GMT
I'm not sure what you're trying to accomplish. It sounds like you've
created a "hashtable" which behaves just like a standard table -- the
hash key is a sequential value, which could just as well be the index
of a simple table.
I don't know what you're trying to retrieve, or why, but assuming you'd
like to get all your RecordIDs, I'd suggest adding a sequential
collision resolver to each record ID, and make the combined field the
key to your hash table. The first record you add with a given RecordID
has a hash key of "RecordID" + "000". Each time you attempt to add a
new record, you check to see if RecordIDnnn exists; if it does, you
increment nnn and check again, until you get a slot. Retrieval is
similarly simple; start with RecordID000, and keep looking until you
get a not found.
Of course, this won't work if you're going to be randomly deleting
records, but it's my best (and only) attempt at trying to understand
what you want to accomplish and suggesting a solution. Good luck.
creator_bob - 18 May 2006 01:00 GMT
How about using an arraylist in your hash table. Everytime you add an
item, if there is something there already, add it to your list.
Cor Ligthert [MVP] - 18 May 2006 06:04 GMT
Rich,
If you have a hashtable and you cannot use the dictionary than probably you
have taken the wrong control.
The meanig from the hashtable is finding things fast by its key.
There is a hybrid by the way, named the sortedlist
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlr
fsystemcollectionssortedlistclasstopic.asp
I hope this helps,
Cor
> Hello,
>
[quoted text clipped - 22 lines]
> Thanks,
> Rich