Skip to content

Deque

Parameters

[DType] 

This is double ended queue with methods to add and pop items from either end. It is implemented using a variable sized ring buffer of fixed sized blocks each capable of holding 16 items.

graph BT
N1["Deque[DType]"] -->|inherits| N2["RandomIterable[DType]"];

Characteristics

Quality Value
Inherits RandomIterable[DType]
Extends N/A
Decorators #sealed;
Is enum false
Is sealed true
Is extern false

Const Expressions

kInitialListSize

const! kInitialListSize = 2

kMultiplyFactor

const! kMultiplyFactor = 2

Subscript

[s Self, index Len] -> @DType

Methods

construct

#default
#Gambol.function.alwaysinline
construct (s Self) -> Self

copy

copy (s Self) -> strictly SelfType
create a new deque with the same items as this one


slice

slice (s Self, range IndexRange) -> SelfType
create a new deque containing items specified by range


fill_with

fill_with (s Self, value @DType, range IndexRange) -> Nil
set the items specified by range to the given value


add

add (s Self, val @DType) -> Nil
same as add_tail


pop

pop (s Self) -> @DType?
same as pop_head


extend

extend (s Self, other nom Iterable[DType]) -> Nil
will add all items in other to the tail of this deque


clear

clear (s Self) -> Nil
remove all items in the deque


add_tail

add_tail (s Self, val @DType) -> Nil
add an item to the tail of the queue


add_head

add_head (s Self, val @DType) -> Nil
add an item to the head of the queue


peek_head

peek_head (s Self) -> @DType?
retrieve the item at the head of the queue without removing it


pop_head

pop_head (s Self) -> DType?
retrieve the item at the head of the queue and remove it


pop_tail

pop_tail (s Self) -> DType?
retrieve the item at the tail of the queue and remove it


rotate

rotate (s Self, n Len) -> Nil
add n items from the head to the tail if n is positive and from the tail to the head if n is negative


len

#strict
len (s Self) -> Len

get_element_ptr_unchecked

get_element_ptr_unchecked (s Self, index Len) -> PointerToVariable[DType]
get a pointer to the item at position index without checking if index is in range


get_element_ptr

get_element_ptr (s Self, index Len) -> PointerToVariable[DType]
get a pointer to the item at position index


get_unchecked

get_unchecked (s Self, index Len) -> @DType
get the item at position index without checking if index is in range


set_unchecked

set_unchecked (s Self, val @DType, index Len) -> Nil
set the item at position index without checking if index is in range


swap_unchecked

swap_unchecked (s Self, a_index Len, b_index Len) -> Nil
swap the items at two indicies without checking if they are in range


str

str (s Self, delimiter: String = `, `, quote_begin: String = ```, quote_end: String = ```, enclose_begin: String = `[`, enclose_end: String = `]`) -> String

get_iterator

get_iterator (s Self) -> ListBidirectionalIterator[Self]

get_reverse_iterator

get_reverse_iterator (s Self) -> ListBidirectionalIterator[Self, -1]

get_random_iterator

get_random_iterator (s Self) -> ListRandomIterator[Self]

__get_block_item_indicies

__get_block_item_indicies (s Self, index Len) -> Len, Len

__range_check

__range_check (s Self, index Len) -> Nil

__get_tail_block

__get_tail_block (s Self) -> @DequeBlock__[DType]

__get_head_block

__get_head_block (s Self) -> @DequeBlock__[DType]

__allocate

__allocate (s Self, is_tail Bool) -> Nil

__deallocate

__deallocate (s Self, is_tail Bool) -> Nil

Binary Operators

is in

is in (s Self, value @DType) -> Bool

==

== (s Self, o Self) -> Bool
two deques are equal if the have the same number of items and all items inside are also equal and in the same order


Properties

__head

__head Len

__tail

__tail Len

__num_blocks

__num_blocks Len

__len

__len Len

__blocks

__blocks List[DequeBlock__[DType]?]