Struct

std::collections::arena_vec::ArenaVec

source

Re-exported from alloc::collections::arena_vec::ArenaVec.

forall T, 'k.
struct ArenaVec { ... }

A growable sequence in an arena whose elements never move: a Copy handle whose copies all name the same vec.

Methods

method newsource

forall C, R where Allocate[C -> 'k, R].
fn new(&cx: C) -> ArenaVec[T, 'k] { ... }

An empty vec. It takes no room for elements until its first one.

method onesource

forall C, R where Allocate[C -> 'k, R].
fn one(&cx: C, value: T) -> ArenaVec[T, 'k] { ... }

A vec holding value.

method twosource

forall C, R where Allocate[C -> 'k, R].
fn two(&cx: C, a: T, b: T) -> ArenaVec[T, 'k] { ... }

A vec holding a then b.

method filledsource

forall C, R where Allocate[C -> 'k, R].
fn filled(&cx: C, count: usize, fill: T) -> ArenaVec[T, 'k] { ... }

count copies of fill.

method lensource

forall C, R where Access[C -> 'k, R].
fn len(self, &cx: C) -> usize { ... }

How many elements the vec holds.

method is_emptysource

forall C, R where Access[C -> 'k, R].
fn is_empty(self, &cx: C) -> bool { ... }

Whether the vec holds no elements.

method addresssource

fn address(self) -> usize { ... }

The vec's identity, as a number: equal for copies of one handle, different for different vecs (Ref::address).

method getsource

forall C, R where Access[C -> 'k, R].
fn get(self, &cx: C, i: usize) -> Option[T] { ... }

Element i, or None past the end.

method atsource

forall C, R where Access[C -> 'k, R].
fn at(self, &cx: C, i: usize) -> T { ... }

Element i, which must be there: past the end, the process stops (core::process::trap).

method get_refsource

forall C, R where Access[C -> 'k, R].
fn get_ref(self, &cx: C, i: usize) -> Option[Ref[T, 'k]] { ... }

Where element i lives, or None past the end. Elements never move, so the place is the element's for as long as the arena lives.

method replacesource

forall C, R where Access[C -> 'k, R].
fn replace(self, &cx: C, i: usize, value: T) -> T { ... }

Puts value at i, which must be there, and hands back the value it replaces.

method setsource

forall C, R where Access[C -> 'k, R].
fn set(self, &cx: C, i: usize, value: T) { ... }

Puts value at i, which must be there.

method firstsource

forall C, R where Access[C -> 'k, R].
fn first(self, &cx: C) -> Option[T] { ... }

The first element, or None when empty.

method lastsource

forall C, R where Access[C -> 'k, R].
fn last(self, &cx: C) -> Option[T] { ... }

The last element, or None when empty.

method pushsource

forall C, R where Allocate[C -> 'k, R].
fn push(self, &cx: C, value: T) { ... }

Adds value at the end, adding a segment first when the vec is full.

method popsource

forall C, R where Access[C -> 'k, R].
fn pop(self, &cx: C) -> Option[T] { ... }

Removes and hands back the last element, or None when empty.

method truncatesource

forall C, R where Access[C -> 'k, R].
fn truncate(self, &cx: C, len: usize) { ... }

Keeps the first len elements; nothing changes when there are no more than that.

method clearsource

forall C, R where Access[C -> 'k, R].
fn clear(self, &cx: C) { ... }

Removes every element, keeping the room.

method resizesource

forall C, R where Allocate[C -> 'k, R].
fn resize(self, &cx: C, len: usize, fill: T) { ... }

Grows to len elements, the new ones set to fill, or keeps the first len.

method appendsource

forall C, R where Allocate[C -> 'k, R].
fn append(self, &cx: C, other: ArenaVec[T, 'k]) { ... }

Pushes every element of other, in order. other may be self.

method clonesource

forall C, R where Allocate[C -> 'k, R].
fn clone(self, &cx: C) -> ArenaVec[T, 'k] { ... }

A new vec holding the same elements.

method concatsource

forall C, R where Allocate[C -> 'k, R].
fn concat(self, &cx: C, other: ArenaVec[T, 'k]) -> ArenaVec[T, 'k] { ... }

The elements of self, then those of other, in a new vec; append adds them to self instead.

method slicesource

forall C, R where Allocate[C -> 'k, R].
fn slice(self, &cx: C, start: usize, end: usize) -> ArenaVec[T, 'k] { ... }

Elements start to end, each clamped to the vec, as a new vec.

method skipsource

forall C, R where Allocate[C -> 'k, R].
fn skip(self, &cx: C, start: usize) -> ArenaVec[T, 'k] { ... }

The elements from start on, as a new vec.

method insertsource

forall C, R where Allocate[C -> 'k, R].
fn insert(self, &cx: C, i: usize, value: T) { ... }

Puts value at i, at most the length, moving the elements from there on one place up.

method removesource

forall C, R where Access[C -> 'k, R].
fn remove(self, &cx: C, i: usize) -> T { ... }

Takes out the element at i, which must be there, moving the ones after it one place down.

method reversesource

forall C, R where Access[C -> 'k, R].
fn reverse(self, &cx: C) { ... }

Reverses the elements in place.

method sort_bysource

forall Env, C, R where Access[C -> 'k, R], Copy[Env].
fn sort_by(self, &cx: C, cmp: closure[Env](&_: C, T, T) -> Order) { ... }

Sorts in place by cmp, keeping equal elements in their order. A short vec is sorted by insertion; a longer one is copied into a heap block of twice its length, merge sorted there bottom-up (O(n log n) comparisons) and copied back, and the block is freed.

method insertion_sortsource

forall Env, C, R where Access[C -> 'k, R], Copy[Env].
fn insertion_sort(self, &cx: C, cmp: closure[Env](&_: C, T, T) -> Order) { ... }

Sorts in place by cmp, stably, by insertion: sort_by's way for a short vec.

method eachsource

forall Env, C, R where Access[C -> 'k, R], Copy[Env].
fn each(self, &cx: C, f: closure[Env](&_: C, T) -> ()) { ... }

f on each element, in order, for what it does through the context.

method find_mapsource

forall U, Env, C, R where Access[C -> 'k, R], Copy[U], Copy[Env].
fn find_map(self, &cx: C, f: closure[Env](&_: C, T) -> Option[U]) -> Option[U] { ... }

The first element f returns a value for, and that value.

method findsource

forall Env, C, R where Access[C -> 'k, R], Copy[Env].
fn find(self, &cx: C, f: closure[Env](&_: C, T) -> bool) -> Option[T] { ... }

The first element f holds for.

method positionsource

forall Env, C, R where Access[C -> 'k, R], Copy[Env].
fn position(self, &cx: C, f: closure[Env](&_: C, T) -> bool) -> Option[usize] { ... }

The index of the first element f holds for.

method anysource

forall Env, C, R where Access[C -> 'k, R], Copy[Env].
fn any(self, &cx: C, f: closure[Env](&_: C, T) -> bool) -> bool { ... }

Whether f holds for some element.

method allsource

forall Env, C, R where Access[C -> 'k, R], Copy[Env].
fn all(self, &cx: C, f: closure[Env](&_: C, T) -> bool) -> bool { ... }

Whether f holds for every element.

method countsource

forall Env, C, R where Access[C -> 'k, R], Copy[Env].
fn count(self, &cx: C, f: closure[Env](&_: C, T) -> bool) -> usize { ... }

How many elements f holds for.

method foldsource

forall A, Env, C, R where Access[C -> 'k, R], Copy[Env].
fn fold(self, &cx: C, acc: A, f: closure[Env](&_: C, A, T) -> A) -> A { ... }

acc through f with each element, in order.

method mapsource

forall U, Env, C, R, Q where Allocate[C -> 'k, R], Access[C -> 'k, Q], Copy[U], Copy[Env], Sized[U].
fn map(self, &cx: C, f: closure[Env](&_: C, T) -> U) -> ArenaVec[U, 'k] { ... }

Each element through f, in a new vec.

method filtersource

forall Env, C, R, Q where Allocate[C -> 'k, R], Access[C -> 'k, Q], Copy[Env].
fn filter(self, &cx: C, f: closure[Env](&_: C, T) -> bool) -> ArenaVec[T, 'k] { ... }

The elements f holds for, in a new vec.

method index_ofsource

forall C, R where Access[C -> 'k, R], HashIn[T, C].
fn index_of(self, &cx: C, value: T) -> Option[usize] { ... }

The index of the first element equal to value.

method containssource

forall C, R where Access[C -> 'k, R], HashIn[T, C].
fn contains(self, &cx: C, value: T) -> bool { ... }

Whether some element equals value.

method eqsource

forall C, R where Access[C -> 'k, R], HashIn[T, C].
fn eq(self, &cx: C, other: ArenaVec[T, 'k]) -> bool { ... }

Whether other has the same length, and equal elements in the same order.

method push_strsource

forall C, R where Allocate[C -> 'k, R].
fn push_str(self, &cx: C, bytes: Str['k]) { ... }

Pushes the bytes of bytes, text of the same domain. The text may view this vec's own bytes (to_str), even ones past its length after a truncate, which the push then overwrites: each byte is read before it is overwritten, as memmove does.

method push_staticsource

forall C, R where Allocate[C -> 'k, R].
fn push_static(self, &cx: C, bytes: Str['static]) { ... }

Pushes the bytes of a literal.

method to_strsource

forall C, R where Allocate[C -> 'k, R].
fn to_str(self, &cx: C) -> Str['k] { ... }

The bytes the vec holds now, as text: a view of them while they fit the first segment, else a copy in one block of the arena. Later pushes do not lengthen it; a set, or a push after a truncate, rewrites the bytes of a view.

method splitsource

forall C, R where Allocate[C -> 'k, R].
fn split(&cx: C, text: Str['k], separator: Str['k]) -> ArenaVec[Str['k], 'k] { ... }

The pieces of text between occurrences of separator, in order: one more than there are occurrences, empty ones included. An empty separator occurs nowhere: the one piece is the whole text.

method joinsource

forall C, R where Allocate[C -> 'k, R].
fn join(self, &cx: C, separator: Str['static]) -> Str['k] { ... }

The pieces' bytes with separator between each two, as one new text: split's inverse.

Instances

instance HashIn[ArenaVec[T, 'k], Domain!['k]]source

forall T, 'k where Copy[T], Sized[T], HashIn[T, Domain!['k]].
instance HashIn[ArenaVec[T, 'k], Domain!['k]] { ... }

In std::collections::arena_vec.

A vec as a key, hashed and compared element by element under the domain's context.