OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __new__ (cls, left_list, right_list, length, maxlen=None) |
def | right (self) |
def | left (self) |
def | __iter__ (self) |
def | __repr__ (self) |
def | maxlen (self) |
def | pop (self, count=1) |
def | popleft (self, count=1) |
def | __lt__ (self, other) |
def | __eq__ (self, other) |
def | __hash__ (self) |
def | __len__ (self) |
def | append (self, elem) |
def | appendleft (self, elem) |
def | extend (self, iterable) |
def | extendleft (self, iterable) |
def | count (self, elem) |
def | remove (self, elem) |
def | reverse (self) |
def | rotate (self, steps) |
def | __reduce__ (self) |
def | __getitem__ (self, index) |
Static Public Attributes | |
index | |
Persistent double ended queue (deque). Allows quick appends and pops in both ends. Implemented using two persistent lists. A maximum length can be specified to create a bounded queue. Fully supports the Sequence and Hashable protocols including indexing and slicing but if you need fast random access go for the PVector instead. Do not instantiate directly, instead use the factory functions :py:func:`dq` or :py:func:`pdeque` to create an instance. Some examples: >>> x = pdeque([1, 2, 3]) >>> x.left 1 >>> x.right 3 >>> x[0] == x.left True >>> x[-1] == x.right True >>> x.pop() pdeque([1, 2]) >>> x.pop() == x[:-1] True >>> x.popleft() pdeque([2, 3]) >>> x.append(4) pdeque([1, 2, 3, 4]) >>> x.appendleft(4) pdeque([4, 1, 2, 3]) >>> y = pdeque([1, 2, 3], maxlen=3) >>> y.append(4) pdeque([2, 3, 4], maxlen=3) >>> y.appendleft(4) pdeque([4, 1, 2], maxlen=3)
def __eq__ | ( | self, | |
other | |||
) |
def __getitem__ | ( | self, | |
index | |||
) |
def __hash__ | ( | self | ) |
def __iter__ | ( | self | ) |
def __len__ | ( | self | ) |
def __lt__ | ( | self, | |
other | |||
) |
def __new__ | ( | cls, | |
left_list, | |||
right_list, | |||
length, | |||
maxlen = None |
|||
) |
def __reduce__ | ( | self | ) |
def __repr__ | ( | self | ) |
def append | ( | self, | |
elem | |||
) |
Return new deque with elem as the rightmost element. >>> pdeque([1, 2]).append(3) pdeque([1, 2, 3])
def appendleft | ( | self, | |
elem | |||
) |
Return new deque with elem as the leftmost element. >>> pdeque([1, 2]).appendleft(3) pdeque([3, 1, 2])
def count | ( | self, | |
elem | |||
) |
Return the number of elements equal to elem present in the queue >>> pdeque([1, 2, 1]).count(1) 2
def extend | ( | self, | |
iterable | |||
) |
Return new deque with all elements of iterable appended to the right. >>> pdeque([1, 2]).extend([3, 4]) pdeque([1, 2, 3, 4])
def extendleft | ( | self, | |
iterable | |||
) |
Return new deque with all elements of iterable appended to the left. NB! The elements will be inserted in reverse order compared to the order in the iterable. >>> pdeque([1, 2]).extendleft([3, 4]) pdeque([4, 3, 1, 2])
def left | ( | self | ) |
Leftmost element in dqueue.
def maxlen | ( | self | ) |
Maximum length of the queue.
def pop | ( | self, | |
count = 1 |
|||
) |
Return new deque with rightmost element removed. Popping the empty queue will return the empty queue. A optional count can be given to indicate the number of elements to pop. Popping with a negative index is the same as popleft. Executes in amortized O(k) where k is the number of elements to pop. >>> pdeque([1, 2]).pop() pdeque([1]) >>> pdeque([1, 2]).pop(2) pdeque([]) >>> pdeque([1, 2]).pop(-1) pdeque([2])
def popleft | ( | self, | |
count = 1 |
|||
) |
Return new deque with leftmost element removed. Otherwise functionally equivalent to pop(). >>> pdeque([1, 2]).popleft() pdeque([2])
def remove | ( | self, | |
elem | |||
) |
Return new deque with first element from left equal to elem removed. If no such element is found a ValueError is raised. >>> pdeque([2, 1, 2]).remove(2) pdeque([1, 2])
def reverse | ( | self | ) |
Return reversed deque. >>> pdeque([1, 2, 3]).reverse() pdeque([3, 2, 1]) Also supports the standard python reverse function. >>> reversed(pdeque([1, 2, 3])) pdeque([3, 2, 1])
def right | ( | self | ) |
Rightmost element in dqueue.
def rotate | ( | self, | |
steps | |||
) |
Return deque with elements rotated steps steps. >>> x = pdeque([1, 2, 3]) >>> x.rotate(1) pdeque([3, 1, 2]) >>> x.rotate(-2) pdeque([3, 1, 2])
|
static |