473,805 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to go to specific row in hashtable based on value - not key?

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
May 17 '06 #1
3 1545
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.

May 17 '06 #2
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.

May 18 '06 #3
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/de...classtopic.asp

I hope this helps,

Cor
"Rich" <Ri**@discussio ns.microsoft.co m> schreef in bericht
news:04******** *************** ***********@mic rosoft.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

May 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
20317
by: Mark | last post by:
I'm using an enumerator to iterate through a HashTable that contains all numeric keys. I'd like to iterarate through the HashTable based on the ordered keys. Is there a quick way to do this? Thanks! -Mark IDictionaryEnumerator myEnumerator = myHashTable.GetEnumerator(); while ( myEnumerator.MoveNext() ) { //Please print ordered by Key ... Response.Write("<BR>" + myEnumerator.Key.ToString() + ", " + myEnumerator.Value.ToString())
5
7732
by: Arjen | last post by:
Hello, Let's say that we have a hashtable with some person objects. This persons have a name. Now I want to sort the people objects inside the hashtable by name. How can the hashtable do this for me? Thanks!
2
2593
by: Wamiq Ansari | last post by:
Hi, I am using a System.Windows.Forms.Label object as key in my Hashtable. One thing that has surprised me is that if I create two Label objects with same properties (ie. Name, TabIndex,Text,Size,Dock) and use them as Key in my Hashtable it doesn't give any error. I thought, generally, in a Hashtable we cannot use two same objects as keys. The Label Objects in this case are being created in a loop and used as keys in a Hashtable.
7
1775
by: Naveen Mukkelli | last post by:
Hi, I'm working on a Client/Server application. Server application needs to keep track of all the clients. I'm planning to use a Hashtable for this purpose. There would be thousands of clients connect to the server application. In this case, according to my plan,
5
3054
by: Pham Nguyen | last post by:
Hello, Is it appropriate to use the CallContext class for storing request-specific data? I have a set of business objects that I'm building. Each class contains a hashtable that maps from a key to an object. Whenever a constructor is called, the hashtable is consulted first to see if an object with that key already exists. If it doesn't, the object is pulled from the database and put inside of the hashtable. I'd like the hashtables to...
2
4578
by: Tony | last post by:
I have this problem - I have a hashtable, containing a list of filenames. Every 60 seconds, I have a thread that enumerates thru this hashtable, and based on some simple logic, some of the items in the hashtable has to be removed. But when I remove a pair from the hashtable, inside the enumeration loop, I get an exception. Why cant I remove from a hashtable, while enumerating ?
10
8985
by: ksrajalakshmi | last post by:
Hai , in a textbox am having text as "(20/100)+pay1*pay2" .it's a formula. and stored in a particular variable. string strformula="(20/100)+pay1*pay2" ; i've to substitute the value of the variable 'pay1' & 'pay2' and finding the value of that strformula. can any onr tell me how to find 'pay1' and 'pay2' in the variable
2
1477
by: BSamp | last post by:
I have the following business entity classes shown below. I have a data layer that retrieves the data from the database and populates a new instance of the PendingRecord class then adds it to the PendingRecords collection. i.e. PendingRecords pendingRecords = dataLayer.GetPendingRecords(); What I would like to do is to be able to have a method in the collection class that I could pass a wizardId and get the specific PendingRecord
15
3100
by: Macca | last post by:
Hi, My app needs to potentially store a large number of custom objects and be able to iterate through them quickly. I was wondering which data structure would be the most efficient to do this,a hashtable or a generic list. Is using enumerators to iterate through the data structure a good idea? I'd appreciate any suggesstions or advice,
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10369
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.