[−][src]Struct ra_ap_la_arena::Arena
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]
&self
) -> impl Iterator<Item = (Idx<T>, &T)> + ExactSizeIterator + DoubleEndedIterator
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]
pub fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = T>,
[src]
I: IntoIterator<Item = T>,
impl<T> Index<Idx<T>> for Arena<T>
[src]
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,
[src]
T: RefUnwindSafe,
impl<T> Send for Arena<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for Arena<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for Arena<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for Arena<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,