◆ __eq__()
def __eq__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
Traverses the lists, checking equality of elements.
This is an O(n) operation, but preserves the standard semantics of list equality.
◆ __getitem__()
def __getitem__ |
( |
|
self, |
|
|
|
index |
|
) |
| |
◆ __hash__()
◆ __iter__()
◆ __len__()
Return the length of the list, computed by traversing it.
This is obviously O(n) but with the current implementation
where a list is also a node the overhead of storing the length
in every node would be quite significant.
◆ __lt__()
def __lt__ |
( |
|
self, |
|
|
|
other |
|
) |
| |
◆ __reduce__()
◆ __repr__()
◆ cons()
Return a new list with elem inserted as new head.
>>> plist([1, 2]).cons(3)
plist([3, 1, 2])
◆ mcons()
def mcons |
( |
|
self, |
|
|
|
iterable |
|
) |
| |
Return a new list with all elements of iterable repeatedly cons:ed to the current list.
NB! The elements will be inserted in the reverse order of the iterable.
Runs in O(len(iterable)).
>>> plist([1, 2]).mcons([3, 4])
plist([4, 3, 1, 2])
◆ remove()
def remove |
( |
|
self, |
|
|
|
elem |
|
) |
| |
Return new list with first element equal to elem removed. O(k) where k is the position
of the element that is removed.
Raises ValueError if no matching element is found.
>>> plist([1, 2, 1]).remove(1)
plist([2, 1])
◆ reverse()
Return a reversed version of list. Runs in O(n) where n is the length of the list.
>>> plist([1, 2, 3]).reverse()
plist([3, 2, 1])
Also supports the standard reversed function.
>>> reversed(plist([1, 2, 3]))
plist([3, 2, 1])
◆ split()
def split |
( |
|
self, |
|
|
|
index |
|
) |
| |
Spilt the list at position specified by index. Returns a tuple containing the
list up until index and the list after the index. Runs in O(index).
>>> plist([1, 2, 3, 4]).split(2)
(plist([1, 2]), plist([3, 4]))
◆ count
◆ index
The documentation for this class was generated from the following file:
- /home/passerat/Stage/flaskProject/venv/lib/python3.8/site-packages/pyrsistent/_plist.py