Struct ra_ap_la_arena::Arena[][src]

pub struct Arena<T> { /* fields omitted */ }
Expand description

Yet another index-based arena.

Implementations

Creates a new empty arena.

let arena: la_arena::Arena<i32> = la_arena::Arena::new();
assert!(arena.is_empty());

Empties the arena, removing all contained values.

let mut arena = la_arena::Arena::new();

arena.alloc(1);
arena.alloc(2);
arena.alloc(3);
assert_eq!(arena.len(), 3);

arena.clear();
assert!(arena.is_empty());

Returns the length of the arena.

let mut arena = la_arena::Arena::new();
assert_eq!(arena.len(), 0);

arena.alloc("foo");
assert_eq!(arena.len(), 1);

arena.alloc("bar");
assert_eq!(arena.len(), 2);

arena.alloc("baz");
assert_eq!(arena.len(), 3);

Returns whether the arena contains no elements.

let mut arena = la_arena::Arena::new();
assert!(arena.is_empty());

arena.alloc(0.5);
assert!(!arena.is_empty());

Allocates a new value on the arena, returning the value’s index.

let mut arena = la_arena::Arena::new();
let idx = arena.alloc(50);

assert_eq!(arena[idx], 50);

Returns an iterator over the arena’s elements.

let mut arena = la_arena::Arena::new();
let idx1 = arena.alloc(20);
let idx2 = arena.alloc(40);
let idx3 = arena.alloc(60);

let mut iterator = arena.iter();
assert_eq!(iterator.next(), Some((idx1, &20)));
assert_eq!(iterator.next(), Some((idx2, &40)));
assert_eq!(iterator.next(), Some((idx3, &60)));

Returns an iterator over the arena’s mutable elements.

let mut arena = la_arena::Arena::new();
let idx1 = arena.alloc(20);

assert_eq!(arena[idx1], 20);

let mut iterator = arena.iter_mut();
*iterator.next().unwrap().1 = 10;
drop(iterator);

assert_eq!(arena[idx1], 10);

Reallocates the arena to make it take up as little space as possible.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Creates a value from an iterator. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Performs the mutable indexing (container[index]) operation. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.