Get Last in HybridDictionary?

  • Thread starter Thread starter localhost
  • Start date Start date
L

localhost

I have a HybridDictionary with 120 key/value pairs. I want to get
pair #120, but if I use GetEnumerator() then I will have to traverse
everything to get the last one... How can I read from the bottom?

Thanks.
 
localhost said:
I have a HybridDictionary with 120 key/value pairs. I want to get
pair #120, but if I use GetEnumerator() then I will have to traverse
everything to get the last one... How can I read from the bottom?

Like Hashtable, I don't believe HybridDictionary guarantees anything
about the order in which GetEnumerator will return results - certainly
don't rely on it being the same order as the one in which you inserted
items. Given that, could I ask what you're trying to do?
 
As some code takes different steps, log-type information is written to
the HybridDictionary. I chose that class so it will stay small
(Dictionary) if there are few log entries, and get fast-lookupable
(Hashtable) if t gets large.

Anyway, later, I will want to look at the last thing that happened,
then the previous one, etc. You're saying that GetEnumerator des not
read the Hashtable in order, so what collection-type class should I
use for this solution?

Thanks.
 
localhost said:
As some code takes different steps, log-type information is written to
the HybridDictionary. I chose that class so it will stay small
(Dictionary) if there are few log entries, and get fast-lookupable
(Hashtable) if t gets large.

Anyway, later, I will want to look at the last thing that happened,
then the previous one, etc. You're saying that GetEnumerator des not
read the Hashtable in order, so what collection-type class should I
use for this solution?

One obvious suggestion is to create both an ArrayList and a Hashtable.
Use the ArrayList for ordering, and the Hashtable for lookups.
 
Back
Top