1 from __future__
import print_function
27 import collections.abc
33 end += [
None, end, end]
35 if iterable
is not None:
42 return key
in self.
map 45 if key
not in self.
map:
48 curr[2] = end[1] = self.
map[key] = [key, curr, end]
52 key, prev, next = self.
map.
pop(key)
59 while curr
is not end:
66 while curr
is not end:
70 def pop(self, last=True):
72 raise KeyError(
'set is empty')
73 key = self.
end[1][0]
if last
else self.
end[2][0]
79 return '%s()' % (self.__class__.__name__,)
80 return '%s(%r)' % (self.__class__.__name__, list(self))
83 if isinstance(other, OrderedSet):
84 return len(self) == len(other)
and list(self) == list(other)
85 return set(self) == set(other)
88 if __name__ ==
'__main__':
97 self.assertEqual(
str((s | t)),
"OrderedSet(['a', 'b', 'r', 'c', 'd', 's', 'i', 'm', 'l'])")
98 self.assertEqual(
str((s & t)),
"OrderedSet(['a', 'b'])")
99 self.assertEqual(
str(s - t),
"OrderedSet(['r', 'c', 'd'])")
def __init__(self, iterable=None)
def __contains__(self, key)
def testSetOperations(self)