Compare commits
2 Commits
09b73c35e6
...
eaaac53be0
Author | SHA1 | Date |
---|---|---|
Nocturn9x | eaaac53be0 | |
Nocturn9x | 11448193ea |
18
README.md
18
README.md
|
@ -29,16 +29,22 @@ queue.addLeft(0)
|
|||
queue.addLeft(-1)
|
||||
queue.addLeft(-2)
|
||||
|
||||
echo queue
|
||||
|
||||
# Pops and returns the first element in O(1) time
|
||||
echo queue.pop()
|
||||
echo queue.pop() # -2
|
||||
|
||||
echo queue
|
||||
|
||||
# Pops and returns the last element in O(1) time
|
||||
echo queue.pop(queue.high()) # 2
|
||||
echo queue.pop(queue.high()) # 3
|
||||
# This can also be written as
|
||||
echo queue.pop(^1) # 1
|
||||
echo queue.pop(^1) # 2
|
||||
|
||||
echo queue
|
||||
|
||||
# Pops element at position 2
|
||||
echo queue.pop(2)
|
||||
echo queue.pop(2) # 1
|
||||
|
||||
# Supports iteration
|
||||
for i, e in queue:
|
||||
|
@ -61,8 +67,8 @@ echo 0 in queue # true
|
|||
# queue, the higher the time it takes to retrieve it. For
|
||||
# fast random access, seqs should be used instead
|
||||
echo queue[0] # -1
|
||||
echo queue[^1] # 2
|
||||
echo queue[queue.high()] # 2
|
||||
echo queue[^1] # 0
|
||||
echo queue[queue.high()] # 0
|
||||
|
||||
|
||||
# It's possible to extend a deque with other deques or with seqs
|
||||
|
|
|
@ -15,26 +15,5 @@ import private/queues/linked
|
|||
|
||||
|
||||
# Exports linked queue stuff
|
||||
export newLinkedDeque
|
||||
export LinkedDeque
|
||||
export add
|
||||
export addLeft
|
||||
export contains
|
||||
export items
|
||||
export reversed
|
||||
export len
|
||||
export linked.high
|
||||
export pop
|
||||
export `[]`
|
||||
export `[]=`
|
||||
export `==`
|
||||
export pairs
|
||||
export linked.`$`
|
||||
export insert
|
||||
export extend
|
||||
export reversedPairs
|
||||
export clear
|
||||
export clearPop
|
||||
export extendLeft
|
||||
export maxSize
|
||||
export find
|
||||
export linked
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ proc clear*[T](self: LinkedDeque[T]) =
|
|||
|
||||
proc clearPop*[T](self: LinkedDeque[T]) =
|
||||
## Clears the deque by repeatedly
|
||||
## calling self.pop() in O(1) time,
|
||||
## calling self.pop() in O(n) time,
|
||||
## slower than clear()
|
||||
while self.len() > 0:
|
||||
discard self.pop()
|
||||
|
|
Loading…
Reference in New Issue