Slice

Slice: Slice, empty, size, front, operator[], operator[-], data, iterator, find, all, any, none

Functions: operator==

struct Slice<Element>: Copyable

A non-owning reference to a contiguous array of elements.

Slice

Slice()

Initializes a Slice referring to an empty array.

implicit Slice(List<Element>& list)

Initializes a Slice referring to the elements of the given List.

Slice(Element* data, int size)

Initializes a Slice referring to an array of the given size located at the given memory address.

empty

bool empty()

Returns true if the array has no elements.

size

int size()

Returns the number of elements in the array.

front

Element& front()

Returns the first element in the array.

operator[]

Element& operator[](int index)

Returns a reference to the element at the given index.

operator[-]

Element& operator[-](int index)

Returns a reference to the element at the given offset from the end. Offset 1 is the last element; offsets outside 1..size() abort.

data

Element[*] data()

Returns a pointer to the first element.

iterator

ArrayIterator<Element> iterator()

Returns an iterator over the elements.

find

Element&? find(bool(Element&) predicate)

Returns the first element satisfying the predicate, or null.

Element&? find<T: Copyable>(bool(T) predicate)

Returns the first element satisfying the predicate, or null.

all

bool all(bool(Element&) predicate)

Returns true if all elements satisfy the predicate.

bool all<T: Copyable>(bool(T) predicate)

Returns true if all elements satisfy the predicate.

any

bool any(bool(Element&) predicate)

Returns true if any element satisfies the predicate.

bool any<T: Copyable>(bool(T) predicate)

Returns true if any element satisfies the predicate.

none

bool none(bool(Element&) predicate)

Returns true if no element satisfies the predicate.

bool none<T: Copyable>(bool(T) predicate)

Returns true if no element satisfies the predicate.

operator==

bool operator==<T>(Slice<T> a, Slice<T> b)

Returns true if both arrays have equal elements.