|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
how to go to specific row in hashtable based on value - not key?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 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. 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. 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/frlrfsystemcollectionssortedlistclasstopic.asp I hope this helps, Cor Show quoteHide quote "Rich" <R***@discussions.microsoft.com> schreef in bericht news:04183246-1519-4A27-A66A-31029B934758@microsoft.com... > 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
Create DB Example - It works, but is it right?
Cannot insert explict value for identity column in table 'Employees' when IDENTITY_INSERT is set to MAPI mail XML From Stored Proc Listbox problem Access locking and transactions Web Browser & Navigating to pages with errors Referring to form objects from inside a thread pool Different versions of Office Conversion of PNG to HTML Files |
|||||||||||||||||||||||