Any such thing as a single column HashTable?

  • Thread starter Thread starter Joseph Geretz
  • Start date Start date
J

Joseph Geretz

Basically, I just need an efficient way to store and retrieve keys from a
list. I don't need key/value pairs. I've implemented this with the standard
HashTable, but the value column is a waste since every key has the same
value, "".

Thanks for your advice.

- Joe Geretz -
 
Array of strings?

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
Networking Components, Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net
 
Basically, I just need an efficient way to store and retrieve keys from a
list. I don't need key/value pairs. I've implemented this with the standard
HashTable, but the value column is a waste since every key has the same
value, "".

So basically you want a set, right? No, there's nothing built into the
framework. Normally people just use HashTable/Dictionary<K,V> and use
a dummy value.

Jon
 
Basically, I just need an efficient way to store and retrieve keys from a
list. I don't need key/value pairs. I've implemented this with the standard
HashTable, but the value column is a waste since every key has the same
value, "".

Thanks for your advice.

- Joe Geretz -

An array?
 
It might be a little early, but there will be the HashSet class in Orcas
which will introduce this class. Just something to be aware of in the
future.
 
Nicholas Paldino said:
It might be a little early, but there will be the HashSet class in Orcas
which will introduce this class. Just something to be aware of in the
future.

Hurrah! Only 5 years after it should have been present :)
 
I can't wait. :-)
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




Nicholas Paldino said:
It might be a little early, but there will be the HashSet class in Orcas
which will introduce this class. Just something to be aware of in the
future.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Jon Skeet said:
So basically you want a set, right? No, there's nothing built into the
framework. Normally people just use HashTable/Dictionary<K,V> and use
a dummy value.

Jon
 
Will this provide as efficient lookup as the HashTable?

No, HashTable is your fastest lookup hands down. Just put an INT in the
data with 0. Then you can just use the keys.
 
EmeraldShield said:
No, HashTable is your fastest lookup hands down. Just put an INT in the
data with 0. Then you can just use the keys.

Using a plain HashTable, that's a really bad idea - the 0 would get
boxed every time. Using something like "" or even making the key also
the value is more efficient.
 
Will this provide as efficient lookup as the HashTable?

What are you trying to look up?

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
Networking Components, Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

Joseph Geretz said:
Hi Rad,
An array?

Will this provide as efficient lookup as the HashTable?

Thanks,

- Joseph Geretz -
 
It might be a little early, but there will be the HashSet class in Orcas
which will introduce this class. Just something to be aware of in the
future.

I was not aware of that until now. I'm guessing it'll have union,
intersection, difference, etc. methods? That would be nice. Thanks
for the tip.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top