diff --git a/README.md b/README.md index 4cb0d6e..25bafaf 100644 --- a/README.md +++ b/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) # 0 +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] # 1 -echo queue[queue.high()] # 1 +echo queue[^1] # 0 +echo queue[queue.high()] # 0 # It's possible to extend a deque with other deques or with seqs