a
ˆåÏh; ã @ sz d Z ddlZddlmZ zddlmZmZ W n" eyN ddlmZmZ Y n0 e dƒZ
dZdd„ ZG dd „ d eeƒZ
dS )
zí
An OrderedSet is a custom MutableSet that remembers its order, so that every
entry has an index that can be looked up.
Based on a recipe originally posted to ActiveState Recipes by Raymond Hettiger,
and released under the MIT license.
é N)Údeque)Ú
MutableSetÚSequencez3.1c C s" t | dƒo t| tƒ o t| tƒ S )a
Are we being asked to look up a list of things, instead of a single thing?
We check for the `__iter__` attribute so that this can cover types that
don't have to be known by this module, such as NumPy arrays.
Strings, however, should be considered as atomic values to look up, not
iterables. The same goes for tuples, since they are immutable and therefore
valid entries.
We don't need to check for the Python 2 `unicode` type, because it doesn't
have an `__iter__` attribute anyway.
Ú__iter__)ÚhasattrÚ
isinstanceÚstrÚtuple)Úobj© r úB/usr/lib/python3.9/site-packages/setuptools/_vendor/ordered_set.pyÚis_iterable s
ÿ
ýr
c @ sþ e Zd ZdZd;dd„Zdd„ Zdd„ Zd d
„ Zdd„ Zd
d„ Z dd„ Z
dd„ ZeZdd„ Z
dd„ ZeZeZdd„ Zdd„ Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd/d0„ Zd1d2„ Zd3d4„ Zd5d6„ Z d7d8„ Z!d9d:„ Z"dS )<Ú
OrderedSetzØ
An OrderedSet is a custom MutableSet that remembers its order, so that
every entry has an index that can be looked up.
Example:
>>> OrderedSet([1, 1, 2, 3, 2])
OrderedSet([1, 2, 3])
Nc C s g | _ i | _|d ur| |O } d S ©N)ÚitemsÚmap)ÚselfÚiterabler r r Ú__init__4 s zOrderedSet.__init__c C s
t | jƒS )zÄ
Returns the number of unique elements in the ordered set
Example:
>>> len(OrderedSet([]))
0
>>> len(OrderedSet([1, 2]))
2
)Úlenr ©r r r r Ú__len__: s
zOrderedSet.__len__c s| t |tƒr|tkrˆ ¡ S t|ƒr4‡ fdd„|D ƒS t|dƒsHt |tƒrlˆ j| }t |tƒrfˆ |¡S |S nt d| ƒ‚dS )aQ
Get the item at a given index.
If `index` is a slice, you will get back that slice of items, as a
new OrderedSet.
If `index` is a list or a similar iterable, you'll get a list of
items corresponding to those indices. This is similar to NumPy's
"fancy indexing". The result is not an OrderedSet because you may ask
for duplicate indices, and the number of elements returned should be
the number of elements asked for.
Example:
>>> oset = OrderedSet([1, 2, 3])
>>> oset[1]
2
c s g | ]}ˆ j | ‘qS r )r )Ú.0Úir r r Ú