Use a DataTable in place of a HashTable

  • Thread starter Thread starter _eee_
  • Start date Start date
E

_eee_

I have been using a HashTable to store name/value pairs, but now I
need to add a third element (name/value/flag). I still need to be
able to index by ["Name"], and I'd like to keep lookup speed as high
as possible.

I'm considering using a DataTable instead of the HashTable since I
have to store the values to a database eventually anyway. It seems
like the DataTable can do what the HashTable is doing in this case,
but I'm concerned about efficiency.

Does anyone happen to know the tradeoffs in using the DataTable
instead? I was originally considering building both tables at the
same time, but that seems unnecessary.
 
Hi,

You might create a custom value class that encapsulates value and flag?
Using a DataTable seems a bit of an overkill to me.
 
_eee_ said:
I have been using a HashTable to store name/value pairs, but now I
need to add a third element (name/value/flag). I still need to be
able to index by ["Name"], and I'd like to keep lookup speed as high
as possible.

I'm considering using a DataTable instead of the HashTable since I
have to store the values to a database eventually anyway.


You might create a custom value class that encapsulates value and flag?
Using a DataTable seems a bit of an overkill to me.

Hi Miha,

You mean slow runtime? I could live with the increased code
complexity of the DataTable as long as it doesn't slow runtime down to
a crawl.
 
Yes, I mean that DataTable has overheads.
Rather use the "holder" class approach.

--
Miha Markic [MVP C#] - RightHand .NET consulting & software development
miha at rthand com
www.rthand.com

_eee_ said:
_eee_ said:
I have been using a HashTable to store name/value pairs, but now I
need to add a third element (name/value/flag). I still need to be
able to index by ["Name"], and I'd like to keep lookup speed as high
as possible.

I'm considering using a DataTable instead of the HashTable since I
have to store the values to a database eventually anyway.


You might create a custom value class that encapsulates value and flag?
Using a DataTable seems a bit of an overkill to me.

Hi Miha,

You mean slow runtime? I could live with the increased code
complexity of the DataTable as long as it doesn't slow runtime down to
a crawl.
 
Back
Top