[][src]Struct beach_map::BeachMap

pub struct BeachMap<V, T> { /* fields omitted */ }

Methods

impl<T> BeachMap<DefaultVersion, T>[src]

pub fn with_capacity(capacity: usize) -> BeachMap<DefaultVersion, T>[src]

Constructs a new, empty BeachMap with the specified capacity and the default version type (u32).

Exemple:

let beach = BeachMap::<_, i32>::with_capacity(5);
assert_eq!(beach.len(), 0);
// or if T can be inferred
let mut beach = BeachMap::with_capacity(5);
beach.insert(10);

pub fn with_version<V: Copy + Clone + Default + PartialEq + AddAssign + From<u8>>(
) -> BeachMap<V, T>
[src]

Constructs a new, empty BeachMap with a custom version type.

Exemple:

let beach = BeachMap::<_, i32>::with_version::<u8>();
// or if T can be inferred
let mut beach = BeachMap::with_version::<u8>();
beach.insert(5);

pub fn with_version_and_capacity<V: Copy + Clone + Default + PartialEq + AddAssign + From<u8>>(
    capacity: usize
) -> BeachMap<V, T>
[src]

Constructs a new, empty BeachMap with the given capacity and a custom version type.

Exemple:

let beach = BeachMap::<_, i32>::with_version_and_capacity::<u8>(5);
// or if T can be inferred
let mut beach = BeachMap::with_version_and_capacity::<u8>(5);
beach.insert(10);

impl<V: Copy + Clone + Default + PartialEq + AddAssign + From<u8>, T> BeachMap<V, T>[src]

pub fn new() -> BeachMap<V, T>[src]

Construct a new, empty BeachMap with a custom version type.

Exemple:

let beach = BeachMap::<u8, i32>::new();

pub fn insert(&mut self, value: T) -> ID<V>[src]

Adds an item to the BeachMap returning an ID.
If you want to insert a self-referencing value, use insert_with_id.

pub fn insert_with_id<F: FnOnce(ID<V>) -> T>(&mut self, f: F) -> ID<V>[src]

Gives to f the future id of the element and insert the result of f to the BeachMap.

pub fn append(&mut self, vec: &mut Vec<T>) -> Vec<ID<V>>[src]

Moves all vec's elements into the BeachMap leaving it empty.

pub fn append_in(&mut self, vec: &mut Vec<T>, container: &mut Vec<ID<V>>)[src]

pub fn extend<I: IntoIterator<Item = T>>(&mut self, iterator: I) -> Vec<ID<V>>[src]

Inserts all elements of iterator into the BeachMap and return an ID for each element.

pub fn get(&self, id: ID<V>) -> Option<&T>[src]

Returns a reference to the element corresponding to id.

pub fn get_mut(&mut self, id: ID<V>) -> Option<&mut T>[src]

Returns a mutable reference to an element corresponding to id.

pub unsafe fn get_unchecked(&self, index: usize) -> &T[src]

Returns a reference to an element without checking if the versions match.

Safety

Should only be used if index is less that ids.len() and the versions match.

pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T[src]

Returns a mutable reference to an element without checking if the versions match.

Safety

Should only be used if index is less than ids.len() and the versions match.

pub fn contains(&self, id: ID<V>) -> bool[src]

Returns true if the BeachMap contains a value for the specified ID.

pub fn remove(&mut self, id: ID<V>) -> Option<T>[src]

Removes an element from the BeachMap and returns it.

pub fn iter(&self) -> Iter<T>[src]

Returns an iterator visiting all values in the BeachMap.

pub fn iter_mut(&mut self) -> IterMut<T>[src]

Returns an iterator visiting all values in the BeachMap and let you mutate them.

Important traits for IterID<'beach, V, T>
pub fn iter_with_id(&self) -> IterID<V, T>[src]

Returns an iterator visiting all values in the BeachMap and their ID.

Important traits for IterMutID<'beach, V, T>
pub fn iter_mut_with_id(&mut self) -> IterMutID<V, T>[src]

Returns an iterator visiting all values in the BeachMap and their ID, values being mutable.

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

Returns the number of elements the BeachMap can hold without reallocating slots or data.

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

Returns the number of elements in the BeachMap.

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

Returns true is the BeachMap contains no elements.

pub fn reserve(&mut self, additional: usize)[src]

Reserves capacity for at least additional more elements.
The function will reserve space regardless of vacant slots.
Meaning some times slots and data may not allocate new space while ids does.

pub fn reserve_exact(&mut self, additional: usize)[src]

Reserves the minimum capacity for exactly additional more elements to be inserted in the given BeachMap.
The function will reserve space regardless of vacant slots.
Meaning some times slots and data may not allocate new space while ids does.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity of the BeachMap as much as possible.

pub fn clear(&mut self)[src]

Clears the BeachMap, removing all values.
It does not affet the capacity.

Important traits for FilterOut<'beach, V, T, F>
pub fn filter_out<F: FnMut(ID<V>, &mut T) -> bool>(
    &mut self,
    f: F
) -> FilterOut<V, T, F>
[src]

Creates an iterator which uses a closure to determine if an element should be removed.
If the closure returns true, then the element is removed and yielded along with its ID.

pub fn retain<F: FnMut(ID<V>, &mut T) -> bool>(&mut self, f: F)[src]

Keep in the BeachMap the elements for which f returns true.

pub fn drain(&mut self) -> Drain<T>[src]

Creates a draining iterator that removes all elements in the BeachMap and yields the removed items.
The elements are removed even if the iterator is only partially consumed or not consumed at all.

Important traits for FilterOut<'beach, V, T, F>
pub fn drain_with_id(
    &mut self
) -> FilterOut<V, T, impl FnMut(ID<V>, &mut T) -> bool>
[src]

Creates a draining iterator that removes all elements in the BeachMap and yields the removed items along with their ID.
Only the elements consumed by the iterator are removed.

pub unsafe fn reserve_ids(&mut self, additional: usize) -> Vec<ID<V>>[src]

Reserves additional ids. Call use_ids to add elements.

Safety

reverve_ids and use_ids can be called in any order and can be called multiple times.
But until you have use additional ids, adding or removing elements from the BeachMap will break it and other methods may panic.

pub unsafe fn use_ids(&mut self, elements: &mut Vec<T>)[src]

Just adds the elements without making ids nor slots for it, use reserve_ids to add ids and slots.
See reserve_ids to know in which situation it is safe.

pub fn data(&self) -> &[T][src]

Returns a slice of the underlying data vector.

pub fn data_mut(&mut self) -> &mut [T][src]

Returns a mutable slice of the underlying data vector.

Trait Implementations

impl<'beach, V: Copy + Clone + Default + PartialEq + AddAssign + From<u8>, T> IntoIterator for &'beach BeachMap<V, T>[src]

type Item = &'beach T

The type of the elements being iterated over.

type IntoIter = Iter<'beach, T>

Which kind of iterator are we turning this into?

impl<'beach, V: Copy + Clone + Default + PartialEq + AddAssign + From<u8>, T> IntoIterator for &'beach mut BeachMap<V, T>[src]

type Item = &'beach mut T

The type of the elements being iterated over.

type IntoIter = IterMut<'beach, T>

Which kind of iterator are we turning this into?

impl<T> Default for BeachMap<DefaultVersion, T>[src]

impl<V: Copy + Clone + Default + PartialEq + AddAssign + From<u8>, T> Index<ID<V>> for BeachMap<V, T>[src]

type Output = T

The returned type after indexing.

impl<V: Copy + Clone + Default + PartialEq + AddAssign + From<u8>, T> IndexMut<ID<V>> for BeachMap<V, T>[src]

Auto Trait Implementations

impl<V, T> Send for BeachMap<V, T> where
    T: Send,
    V: Send

impl<V, T> Sync for BeachMap<V, T> where
    T: Sync,
    V: Sync

Blanket Implementations

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

impl<T> From for T[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

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

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

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

The type returned in the event of a conversion error.