Skip to content

List

Parameters

[DType = Dynamic] 

Represents a list of items of type DType. Memory is a contiguous block of memory enough to hold the number of items in the list or more. Items can be added to and removed from the list and the underlying memory will be adjusted accordingly. This list is not thread safe.

graph BT
N1["List[DType]"] -->|inherits| N2["RandomModifiableIterable[DType]"];

Characteristics

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

Subscript

[s Self, index Len] -> @DType

access the item at index. If index is out of bounds an exception of type IndexOutOfRangeException will be raised.

Methods

construct

construct (s Self, capacity Len = 0) -> Self
contructs a new list. If capacity > 0 then the list will preallocate enough memory to hold that many items


copy

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


get_element_ptr

#Gambol.function.alwaysinline
get_element_ptr (s Self, index Len) -> PointerToVariable[DType]
get a pointer to the element at index. if index is out of bounds an exception of type IndexOutOfRangeException will be raised


get_element_ptr_unchecked

#Gambol.function.alwaysinline
get_element_ptr_unchecked (s Self, index ULen) -> PointerToVariable[DType]
get a pointer to the element at index without checking if index is in bounds


len

#Gambol.function.alwaysinline
#strict
len (s Self) -> Len
number of items in the list


get_iterator

get_iterator (s Self) -> ListBidirectionalModifiableIterator[Self]

get_reverse_iterator

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

get_random_iterator

get_random_iterator (s Self) -> ListRandomModifiableIterator[Self]

get_unchecked

#Gambol.function.alwaysinline
get_unchecked (s Self, index ULen) -> @DType
get item at position index without bounds checking


set_unchecked

#Gambol.function.alwaysinline
set_unchecked (s Self, value @DType, index ULen) -> Nil
set item at position index without bounds checking


slice

slice (s Self, range IndexRange) -> SelfType
create a new list 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


push

push (s Self, value @DType, count: ULen = 1) -> Nil
same as add


add

add (s Self, value @DType, count: ULen = 1) -> Nil
will add value count number of items to the end of the list


extend

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


insert

insert (s Self, value @DType, index Len, count: ULen = 1) -> Nil
will insert count number of values at the specified index pushing other elements aside


insert_all

insert_all (s Self, other nom Unpackable[DType], index Len) -> Nil
will insert all elements in other at the specified index pushing other elements aside


swap_unchecked

#Gambol.function.alwaysinline
swap_unchecked (s Self, a_index Len, b_index Len) -> Nil
swap elements at the specified two indices without bounds checking


erase

erase (s Self, index Len, count: Len = 1) -> Nil
erase count number of elements at index and resize the list


remove

remove (s Self, val DType, range: IndexRange = IndexRange(), count: Len = 1) -> Nil
remove all items that equal val within the specified range up to count number of times


pop

pop (s Self, count: Len = 1) -> DType
remove the last count items from the list


clear

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


str

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

__list_init

__list_init (s Self, capacity Len = 0) -> Self

__list_drop

__list_drop (s Self) -> Nil

__resize

__resize (s Self, new_len Len) -> Nil

__allocate

__allocate (s Self, len Len) -> Nil

Binary Operators

is in

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

==

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


Properties

kMinCapacity

const global kMinCapacity Len = 10

__1_ptr

__1_ptr PointerToVariable[DType]

__2_len

__2_len Len

__3_capacity

__3_capacity Len

__has_atomic_memory

__has_atomic_memory Bool