[][src]Struct gen_indices::GenIndexEntitySet

pub struct GenIndexEntitySet<I: Num + AddAssign + Copy, G: Num + AddAssign + Copy> { /* fields omitted */ }

GenIndexEntitySet This maintains the "state" for your entities. It is designed with a Mutex, so that it is rendered thread safe.

Example:

extern crate gen_indices;
extern crate num;
 
use gen_indices::*;
use num::{Num, zero, one};

let gi = GenIndexEntitySet::<u64, u64>::new();

// first index
let idx1 = gi.lock().unwrap().next_index();
println!("first: {:?}", idx1);

// second index
let idx2 = gi.lock().unwrap().next_index();
println!("first: {:?}", idx2);

// delete first index and then get next index
if let Err(e) = gi.lock().unwrap().delete_index(idx1) {
    println!("Error: {}", e);
}
let idx3 = gi.lock().unwrap().next_index();
println!("first: {:?}", idx3);

Implementations

impl<I: Num + AddAssign + Copy, G: Num + AddAssign + Copy> GenIndexEntitySet<I, G>[src]

pub fn new() -> Arc<Mutex<GenIndexEntitySet<I, G>>>[src]

Create a new GenIndexEntitySet object, wrapped with a Mutex to allow for thread safety.

pub fn next_index(&mut self) -> GenIndex<I, G>[src]

allocate and provide a "new" index. If an old index was deleted, that index is reused, with the generation number incremented, so that references to the deleted entity are not found.

You are responsible for the corresponding maitenence in your ECS.

pub fn delete_index(&mut self, gi: GenIndex<I, G>) -> Result<(), &'static str>[src]

Delete an entity's index. You will be responsible for the cleanup in the corresponding ECS.

Trait Implementations

impl<I: Clone + Num + AddAssign + Copy, G: Clone + Num + AddAssign + Copy> Clone for GenIndexEntitySet<I, G>[src]

impl<I: Debug + Num + AddAssign + Copy, G: Debug + Num + AddAssign + Copy> Debug for GenIndexEntitySet<I, G>[src]

impl<I: Hash + Num + AddAssign + Copy, G: Hash + Num + AddAssign + Copy> Hash for GenIndexEntitySet<I, G>[src]

impl<I: PartialEq + Num + AddAssign + Copy, G: PartialEq + Num + AddAssign + Copy> PartialEq<GenIndexEntitySet<I, G>> for GenIndexEntitySet<I, G>[src]

impl<I: Num + AddAssign + Copy, G: Num + AddAssign + Copy> StructuralPartialEq for GenIndexEntitySet<I, G>[src]

Auto Trait Implementations

impl<I, G> RefUnwindSafe for GenIndexEntitySet<I, G> where
    G: RefUnwindSafe,
    I: RefUnwindSafe

impl<I, G> Send for GenIndexEntitySet<I, G> where
    G: Send,
    I: Send

impl<I, G> Sync for GenIndexEntitySet<I, G> where
    G: Sync,
    I: Sync

impl<I, G> Unpin for GenIndexEntitySet<I, G> where
    G: Unpin,
    I: Unpin

impl<I, G> UnwindSafe for GenIndexEntitySet<I, G> where
    G: UnwindSafe,
    I: 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.