Struct ra_ap_la_arena::Arena[][src]

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

Yet another index-based arena.

Implementations

impl<T> Arena<T>[src]

pub const fn new() -> Arena<T>[src]

Creates a new empty arena.

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

pub fn clear(&mut self)[src]

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());

pub fn len(&self) -> usize[src]

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);

pub fn is_empty(&self) -> bool[src]

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());

pub fn alloc(&mut self, value: T) -> Idx<T>[src]

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);

pub fn iter(
    &self
) -> impl Iterator<Item = (Idx<T>, &T)> + ExactSizeIterator + DoubleEndedIterator
[src]

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)));

pub fn shrink_to_fit(&mut self)[src]

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

Trait Implementations

impl<T: Clone> Clone for Arena<T>[src]

impl<T: Debug> Debug for Arena<T>[src]

impl<T> Default for Arena<T>[src]

impl<T: Eq> Eq for Arena<T>[src]

impl<T> FromIterator<T> for Arena<T>[src]

impl<T> Index<Idx<T>> for Arena<T>[src]

type Output = T

The returned type after indexing.

impl<T> IndexMut<Idx<T>> for Arena<T>[src]

impl<T: PartialEq> PartialEq<Arena<T>> for Arena<T>[src]

impl<T> StructuralEq for Arena<T>[src]

impl<T> StructuralPartialEq for Arena<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Arena<T> where
    T: RefUnwindSafe

impl<T> Send for Arena<T> where
    T: Send

impl<T> Sync for Arena<T> where
    T: Sync

impl<T> Unpin for Arena<T> where
    T: Unpin

impl<T> UnwindSafe for Arena<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.