pds4_tools.extern.ordered_dict module¶
- class OrderedDict(*args, **kwds)[source]¶
Bases:
dict
Dictionary that remembers insertion order, for Python 2.6 and below
Code from: http://code.activestate.com/recipes/576693/ An inherited dict maps keys to values. The inherited dict provides __getitem__, __len__, __contains__, and get. The remaining methods are order-aware. Big-O running times for all methods are the same as for regular dictionaries.
The internal self.__map dictionary maps keys to links in a doubly linked list. The circular doubly linked list starts and ends with a sentinel element. The sentinel element never gets deleted (this simplifies the algorithm). Each link is stored as a list of length three: [PREV, NEXT, KEY].
- popitem(last=True)[source]¶
Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
- update([E, ]**F) None. Update D from dict/iterable E and F. [source]¶
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
- pop(k[, d]) v, remove specified key and return the corresponding value. [source]¶
If the key is not found, return the default if given; otherwise, raise a KeyError.
- setdefault(key, default=None)[source]¶
Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.