MCPcopy Create free account
hub / github.com/grantjenks/python-sortedcontainers / SortedDict

Class SortedDict

sortedcontainers/sorteddict.py:43–616  ·  view source on GitHub ↗

Sorted dict is a sorted mutable mapping. Sorted dict keys are maintained in sorted order. The design of sorted dict is simple: sorted dict inherits from dict to store items and maintains a sorted list of keys. Sorted dict keys must be hashable and comparable. The hash and total

Source from the content-addressed store, hash-verified

41
42
43class SortedDict(dict):
44 """Sorted dict is a sorted mutable mapping.
45
46 Sorted dict keys are maintained in sorted order. The design of sorted dict
47 is simple: sorted dict inherits from dict to store items and maintains a
48 sorted list of keys.
49
50 Sorted dict keys must be hashable and comparable. The hash and total
51 ordering of keys must not change while they are stored in the sorted dict.
52
53 Mutable mapping methods:
54
55 * :func:`SortedDict.__getitem__` (inherited from dict)
56 * :func:`SortedDict.__setitem__`
57 * :func:`SortedDict.__delitem__`
58 * :func:`SortedDict.__iter__`
59 * :func:`SortedDict.__len__` (inherited from dict)
60
61 Methods for adding items:
62
63 * :func:`SortedDict.setdefault`
64 * :func:`SortedDict.update`
65
66 Methods for removing items:
67
68 * :func:`SortedDict.clear`
69 * :func:`SortedDict.pop`
70 * :func:`SortedDict.popitem`
71
72 Methods for looking up items:
73
74 * :func:`SortedDict.__contains__` (inherited from dict)
75 * :func:`SortedDict.get` (inherited from dict)
76 * :func:`SortedDict.peekitem`
77
78 Methods for views:
79
80 * :func:`SortedDict.keys`
81 * :func:`SortedDict.items`
82 * :func:`SortedDict.values`
83
84 Methods for miscellany:
85
86 * :func:`SortedDict.copy`
87 * :func:`SortedDict.fromkeys`
88 * :func:`SortedDict.__reversed__`
89 * :func:`SortedDict.__eq__` (inherited from dict)
90 * :func:`SortedDict.__ne__` (inherited from dict)
91 * :func:`SortedDict.__repr__`
92 * :func:`SortedDict._check`
93
94 Sorted list methods available (applies to keys):
95
96 * :func:`SortedList.bisect_left`
97 * :func:`SortedList.bisect_right`
98 * :func:`SortedList.count`
99 * :func:`SortedList.index`
100 * :func:`SortedList.irange`

Callers 15

issue_147.pyFile · 0.90
test_initFunction · 0.90
test_stressFunction · 0.90
test_initFunction · 0.90
test_init_keyFunction · 0.90
test_init_argsFunction · 0.90
test_init_kwargsFunction · 0.90
test_clearFunction · 0.90
test_containsFunction · 0.90
test_delitemFunction · 0.90
test_getitemFunction · 0.90
test_eqFunction · 0.90

Calls 1

_NotGivenClass · 0.85

Tested by 15

test_initFunction · 0.72
test_stressFunction · 0.72
test_initFunction · 0.72
test_init_keyFunction · 0.72
test_init_argsFunction · 0.72
test_init_kwargsFunction · 0.72
test_clearFunction · 0.72
test_containsFunction · 0.72
test_delitemFunction · 0.72
test_getitemFunction · 0.72
test_eqFunction · 0.72
test_iterFunction · 0.72