[−][src]Struct dcc_lsystem::arena::Arena
A simple arena wrapping around a Vec
Examples
use dcc_lsystem::Arena; let mut arena = Arena::new(); let u = arena.push(1); let v = arena.push(2); assert_eq!(arena.len(), 2); assert_eq!(arena.get(u), Some(&1));
Methods
impl<T> Arena<T>
[src]
pub fn new() -> Self
[src]
Creates a new empty arena.
Example
use dcc_lsystem::Arena; let mut arena = Arena::new(); arena.push(1); arena.push(3);
pub fn len(&self) -> usize
[src]
Returns the length of this arena.
Example
use dcc_lsystem::Arena; let mut arena = Arena::new(); for i in 0..420 { arena.push(i); } assert_eq!(arena.len(), 420);
pub fn is_empty(&self) -> bool
[src]
Returns true
if the arena contains no elements.
Example
use dcc_lsystem::Arena; let mut arena = Arena::new(); assert!(arena.is_empty()); arena.push(3); assert!(!arena.is_empty());
pub fn get(&self, id: ArenaId) -> Option<&T>
[src]
Returns a reference to an entry of the arena, if the provided ArenaId is valid.
Example
use dcc_lsystem::Arena; let mut arena = Arena::new(); let x = arena.push("x"); let y = arena.push("y"); let z = arena.push("z"); assert_eq!(arena.get(y), Some(&"y"));
pub fn get_mut(&mut self, id: ArenaId) -> Option<&mut T>
[src]
Returns a mutable reference to the entry corresponding to the given index.
Example
use dcc_lsystem::Arena; let mut arena = Arena::new(); let x = arena.push("x"); if let Some(entry) = arena.get_mut(x) { *entry = "y"; } assert_eq!(arena.get(x), Some(&"y"));
pub fn iter(&self) -> Iter<T>
[src]
Returns an iterator over this arena.
Example
use dcc_lsystem::Arena; let mut arena = Arena::new(); let x = arena.push(3); let y = arena.push(5); let mut iterator = arena.iter(); assert_eq!(iterator.next(), Some(&3)); assert_eq!(iterator.next(), Some(&5)); assert_eq!(iterator.next(), None)
pub fn iter_mut(&mut self) -> IterMut<T>
[src]
Returns an iterator that allows modifying each value.
Example
use dcc_lsystem::Arena; let mut arena = Arena::new(); let x = arena.push(3); let y = arena.push(-4); for entry in arena.iter_mut() { *entry = *entry * *entry; } let mut iterator = arena.iter(); assert_eq!(iterator.next(), Some(&9)); assert_eq!(iterator.next(), Some(&16));
pub fn is_valid(&self, id: ArenaId) -> bool
[src]
Returns true if the provided id corresponds to an element of this arena.
use dcc_lsystem::{Arena, ArenaId}; let mut arena = Arena::new(); let x = arena.push(17); let y = arena.push(21); assert!(arena.is_valid(x)); assert!(arena.is_valid(y)); assert!(!arena.is_valid(ArenaId(2)));
pub fn is_valid_slice(&self, slice: &[ArenaId]) -> bool
[src]
Returns true
if the every id in the provided slice is valid.
Example
use dcc_lsystem::{Arena, ArenaId}; let mut arena = Arena::new(); let x = arena.push(1); let y = arena.push(3); let z = arena.push(7); assert!(arena.is_valid_slice(&[x,y])); assert!(arena.is_valid_slice(&[x,y,z])); assert!(!arena.is_valid_slice(&[x,y,ArenaId(3)]));
pub fn push(&mut self, value: T) -> ArenaId
[src]
Add a new value to our arena.
Returns an ArenaId which uniquely identifies this element of the arena.
Example
use dcc_lsystem::Arena;
let mut arena = Arena::new(); let x = arena.push(11); let y = arena.push(-3);
assert_eq!(x, ArenaId(0)); assert_eq!(y, ArenaId(1));
ⓘImportant traits for EnumerableArena<'a, T>pub fn enumerate(&self) -> EnumerableArena<T>
[src]
Returns an EnumerableArena.
Example
use dcc_lsystem::Arena; let mut arena = Arena::new(); let x = arena.push(3); let y = arena.push(5); let z = arena.push(-7); for (id, entry) in arena.enumerate() { /* do some work here */ }
impl Arena<Token>
[src]
pub fn render(&self, tokens: &[ArenaId]) -> String
[src]
Returns a string representation of the given slice of ArenaId's in terms of the contents of this arena.
Trait Implementations
impl<T> Default for Arena<T>
[src]
impl<T: Clone> Clone for Arena<T>
[src]
fn clone(&self) -> Arena<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for Arena<T>
[src]
Auto Trait Implementations
impl<T> Sync for Arena<T> where
T: Sync,
T: Sync,
impl<T> Send for Arena<T> where
T: Send,
T: Send,
impl<T> Unpin for Arena<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Arena<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for Arena<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> SetParameter for T
[src]
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
[src]
T: Parameter<Self>,
Sets value
as a parameter of self
.
impl<Src, Dst> ValueInto<Dst> for Src where
Dst: ValueFrom<Src>,
Dst: ValueFrom<Src>,
type Err = <Dst as ValueFrom<Src>>::Err
The error type produced by a failed conversion.
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Src where
Scheme: ApproxScheme,
Scheme: ApproxScheme,
type Err = NoError
The error type produced by a failed conversion.
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
impl<T> ConvUtil for T
fn approx_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Self: ApproxInto<Dst, DefaultApprox>,
Approximate the subject to a given type with the default scheme.
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
Approximate the subject to a given type with a specific scheme.
fn into_as<Dst>(self) -> Dst where
Self: Into<Dst>,
Self: Into<Dst>,
Convert the subject to a given type.
fn try_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: TryInto<Dst>,
Self: TryInto<Dst>,
Attempt to convert the subject to a given type.
fn value_as<Dst>(self) -> Result<Dst, Self::Err> where
Self: ValueInto<Dst>,
Self: ValueInto<Dst>,
Attempt a value conversion of the subject to a given type.
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Src where
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
The error type produced by a failed conversion.
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
impl<Src> ValueFrom<Src> for Src
type Err = NoError
The error type produced by a failed conversion.
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
impl<T, Dst> ConvAsUtil<Dst> for T
fn approx(self) -> Result<Dst, Self::Err> where
Self: ApproxInto<Dst, DefaultApprox>,
Self: ApproxInto<Dst, DefaultApprox>,
Approximate the subject with the default scheme.
fn approx_by<Scheme>(self) -> Result<Dst, Self::Err> where
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Self: ApproxInto<Dst, Scheme>,
Approximate the subject with a specific scheme.
impl<Src> TryFrom<Src> for Src
type Err = NoError
The error type produced by a failed conversion.
fn try_from(src: Src) -> Result<Src, <Src as TryFrom<Src>>::Err>
impl<Src, Dst> TryInto<Dst> for Src where
Dst: TryFrom<Src>,
Dst: TryFrom<Src>,
type Err = <Dst as TryFrom<Src>>::Err
The error type produced by a failed conversion.
fn try_into(self) -> Result<Dst, <Src as TryInto<Dst>>::Err>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> Clone for T where
T: Clone,
[src]
T: Clone,