[][src]Struct rate_common::memory::Array

pub struct Array<I: Offset, T> {
    pub data: Vector<T>,
    pub phantom: PhantomData<I>,
}

A contiguous non-growable array type with strongly-typed indexing.

The first template argument specifies the type that can be used for indexing the array. The second template argument specifies the type of the elements in the array.

An Array can be used as a fixed size map or set data structure. The maximum index must be set at construction time, which will allocate an area of memory of that size. As a result, this can be quite memory-consuming for sparse maps or sets, but it is as efficient as it gets for fast lookups.

Fields

data: Vector<T>

The vector of elements

phantom: PhantomData<I>

Zero-sized field to appease the compiler, since I is not used in any other field

Methods

impl<I: Offset, T: Clone> Array<I, T>[src]

pub fn new(value: T, size: usize) -> Array<I, T>[src]

Create a new array of size size with all elements set to value.

impl<I: Offset, T> Array<I, T>[src]

pub fn with_capacity(size: usize) -> Array<I, T>[src]

Create a new array of size size without initializing its elements.

pub fn from(data: Vector<T>) -> Array<I, T>[src]

Create a new array by taking ownership of a Vector.

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

Returns the size of the array.

Trait Implementations

impl<I: Offset, T: HeapSpace> HeapSpace for Array<I, T>[src]

impl<I: Eq + Offset, T: Eq> Eq for Array<I, T>[src]

impl<I: Offset, T> AsMut<Array<I, T>> for Array<I, T>[src]

impl<I: Offset, T> AsMut<[T]> for Array<I, T>[src]

impl<I: Offset, T> Default for Array<I, T>[src]

impl<I: Clone + Offset, T: Clone> Clone for Array<I, T>[src]

impl<I: Offset, T> AsRef<Array<I, T>> for Array<I, T>[src]

impl<I: Offset, T> AsRef<[T]> for Array<I, T>[src]

impl<I: PartialEq + Offset, T: PartialEq> PartialEq<Array<I, T>> for Array<I, T>[src]

impl<I: Offset, T> Deref for Array<I, T>[src]

type Target = [T]

The resulting type after dereferencing.

impl<I: Offset, T> DerefMut for Array<I, T>[src]

impl<I: Offset, T> Index<I> for Array<I, T>[src]

type Output = T

The returned type after indexing.

impl<I: Offset, T> IndexMut<I> for Array<I, T>[src]

impl<I: Debug + Offset, T: Debug> Debug for Array<I, T>[src]

Auto Trait Implementations

impl<I, T> Send for Array<I, T> where
    I: Send,
    T: Send

impl<I, T> Unpin for Array<I, T> where
    I: Unpin,
    T: Unpin

impl<I, T> Sync for Array<I, T> where
    I: Sync,
    T: Sync

impl<I, T> UnwindSafe for Array<I, T> where
    I: UnwindSafe,
    T: UnwindSafe

impl<I, T> RefUnwindSafe for Array<I, T> where
    I: RefUnwindSafe,
    T: RefUnwindSafe

Blanket Implementations

impl<T> HeapSpace for T where
    T: Copy
[src]

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

type Owned = T

The resulting type after obtaining ownership.

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

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

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.

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

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

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