I'm looking for the most ideal data structure (for performance and ease of use) from which values can be retrieved by string key or index. Dictionary doesn't work because you can't really retrieve by index. Any ideas?
...
I don't know why this doesn't work:
I'm using the odict class from PEP 372, but I want to use it as a __dict__ member, i.e.:
class Bag(object):
def __init__(self):
self.__dict__ = odict()
But for some reason I'm getting weird results. This works:
>>> b = Bag()
>>> b.apple = 1
>>> b.apple
1
>>> b.banana = 2
>>> b.banana
2...
I've seen (and written) a number of implementations of this. Is there one that is considered the best or is emerging as a standard?
What I mean by ordered dict is that the object has some concept of the order of the keys in it, similar to an array in PHP.
odict from PEP 372 seems like a strong candidate, but it's not totally clear tha...
How to get the key and value of item from OrderedDictionary by index?
...
I'm using .NET 3.5. I think I know the answer to this, but am looking for confirmation so should be a quick one!
There doesn't appear to be a generic implementation of OrderedDictionary (which is in System.Collections.Specialized namespace). Is there one that I'm missing?
I've found implementations out there to provide the functionali...
I am considering of using the OrderedDictionary. As a key I want to use a long value (id) and the value will be a custom object.
I use the OrderedDictionary because I want to get an object by it's Id and I want to get an object by it's 'collection' index.
I want to use the OrderedDictionary like this:
public void AddObject(MyObject ob...