‣ IsQueue ( arg ) | ( filter ) |
Returns: true
or false
The category of queues.
‣ IsDeque ( arg ) | ( filter ) |
Returns: true
or false
The category of deques.
‣ PushBack ( deque, object ) | ( operation ) |
Add object to the back of deque.
‣ PushFront ( deque, object ) | ( operation ) |
Add object to the front of deque.
‣ PopBack ( deque ) | ( operation ) |
Returns: object
Remove an element from the back of deque and return it.
‣ PopFront ( deque ) | ( operation ) |
Returns: object
Remove an element from the front of deque and return it.
For queues, this is just an alias for PushBack
‣ Enqueue ( queue, object ) | ( operation ) |
Add object to queue.
‣ Dequeue ( queue ) | ( operation ) |
Returns: object
Remove an object from the front of queue and return it.
‣ Capacity ( arg ) | ( attribute ) |
Allocated storage capacity of queue.
‣ Capacity ( arg ) | ( attribute ) |
Allocated storage capacity of deque.
‣ Length ( arg ) | ( attribute ) |
Number of elements in queue.
‣ Length ( arg ) | ( attribute ) |
Number of elements in deque.
datastructures implements deques using a circular buffer stored in a GAP a plain list, wrapped in a positional object (Reference: Positional Objects).
The five positions in such a deque Q
have the following purpose
Q![1]
- head, the index in Q![5]
of the first element in the deque
Q![2]
- tail, the index in Q![5]
of the last element in the deque
Q![3]
- capacity, the allocated capacity in the deque
Q![4]
- factor by which storage is increased if capacity is exceeded
Q![5]
- GAP plain list with storage for capacity many entries
Global constants QHEAD
, QTAIL
, QCAPACITY
, QFACTOR
, and QDATA
are bound to reflect the above.
When a push fills the deque, its capacity is resized by a factor of QFACTOR
using PlistDequeExpand. A new empty plist is allocated and all current entries of the deque are copied into the new plist with the head entry at index 1.
The deque is empty if and only if head = tail and the entry that head and tail point to in the storage list is unbound.
‣ PlistDeque ( [capacity[, factor]] ) | ( function ) |
Returns: a deque
Constructor for plist based deques. The optional argument capacity must be a positive integer and is the capacity of the created deque, and the optional argument factor must be a rational number greater than one which is the factor by which the storage of the deque is increased if it runs out of capacity when an object is put on the queue.
‣ PlistDequePushFront ( deque, object ) | ( function ) |
Push object to the front of deque.
‣ PlistDequePushBack ( deque, object ) | ( function ) |
Push object to the back of deque.
‣ PlistDequePopFront ( deque ) | ( function ) |
Returns: object or fail
Pop object from the front of deque and return it. If deque is empty, returns fail
.
‣ PlistDequePopBack ( deque ) | ( function ) |
Returns: object or fail
Pop object from the back of deque and return it. If deque is empty, returns fail
.
‣ PlistDequePeekFront ( deque ) | ( function ) |
Returns: object or fail
Returns the object at the front deque without removing it. If deque is empty, returns fail
.
‣ PlistDequePeekBack ( deque ) | ( function ) |
Returns: object or fail
Returns the object at the back deque without removing it. If deque is empty, returns fail
.
‣ PlistDequeExpand ( deque ) | ( function ) |
Helper function to expand the capacity of deque by the configured factor.
Queues are linear data structure that allow adding elements at the end of the queue, and removing elements from the front. A deque is a double-ended queue; a linear data structure that allows access to objects at both ends.
The API that objects that lie in IsQueue
(4.1-1) and IsDeque
(4.1-2) must implement the API set out below.
datastructures provides
generated by GAPDoc2HTML