Skip to main content

OrderedRelationshipSourceCollection

Trait OrderedRelationshipSourceCollection 

pub trait OrderedRelationshipSourceCollection: RelationshipSourceCollection {
    // Required methods
    fn insert(&mut self, index: usize, entity: Entity);
    fn remove_at(&mut self, index: usize) -> Option<Entity>;
    fn insert_stable(&mut self, index: usize, entity: Entity);
    fn remove_at_stable(&mut self, index: usize) -> Option<Entity>;
    fn sort(&mut self);
    fn insert_sorted(&mut self, entity: Entity);
    fn place_most_recent(&mut self, index: usize);
    fn place(&mut self, entity: Entity, index: usize);

    // Provided methods
    fn push_front(&mut self, entity: Entity) { ... }
    fn push_back(&mut self, entity: Entity) { ... }
    fn pop_front(&mut self) -> Option<Entity> { ... }
    fn pop_back(&mut self) -> Option<Entity> { ... }
}
Expand description

This trait signals that a RelationshipSourceCollection is ordered.

Required Methods§

fn insert(&mut self, index: usize, entity: Entity)

Inserts the entity at a specific index. If the index is too large, the entity will be added to the end of the collection.

fn remove_at(&mut self, index: usize) -> Option<Entity>

Removes the entity at the specified index if it exists.

fn insert_stable(&mut self, index: usize, entity: Entity)

Inserts the entity at a specific index. This will never reorder other entities. If the index is too large, the entity will be added to the end of the collection.

fn remove_at_stable(&mut self, index: usize) -> Option<Entity>

Removes the entity at the specified index if it exists. This will never reorder other entities.

fn sort(&mut self)

Sorts the source collection.

fn insert_sorted(&mut self, entity: Entity)

Inserts the entity at the proper place to maintain sorting.

fn place_most_recent(&mut self, index: usize)

This places the most recently added entity at the particular index.

fn place(&mut self, entity: Entity, index: usize)

This places the given entity at the particular index. This will do nothing if the entity is not in the collection. If the index is out of bounds, this will put the entity at the end.

Provided Methods§

fn push_front(&mut self, entity: Entity)

Adds the entity at index 0.

fn push_back(&mut self, entity: Entity)

Adds the entity to the back of the collection.

fn pop_front(&mut self) -> Option<Entity>

Removes the first entity.

fn pop_back(&mut self) -> Option<Entity>

Removes the last entity.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

§

impl OrderedRelationshipSourceCollection for Vec<Entity>

§

fn insert(&mut self, index: usize, entity: Entity)

§

fn remove_at(&mut self, index: usize) -> Option<Entity>

§

fn insert_stable(&mut self, index: usize, entity: Entity)

§

fn remove_at_stable(&mut self, index: usize) -> Option<Entity>

§

fn sort(&mut self)

§

fn insert_sorted(&mut self, entity: Entity)

§

fn place_most_recent(&mut self, index: usize)

§

fn place(&mut self, entity: Entity, index: usize)

§

impl<const N: usize> OrderedRelationshipSourceCollection for SmallVec<[Entity; N]>

§

fn insert(&mut self, index: usize, entity: Entity)

§

fn remove_at(&mut self, index: usize) -> Option<Entity>

§

fn insert_stable(&mut self, index: usize, entity: Entity)

§

fn remove_at_stable(&mut self, index: usize) -> Option<Entity>

§

fn sort(&mut self)

§

fn insert_sorted(&mut self, entity: Entity)

§

fn place_most_recent(&mut self, index: usize)

§

fn place(&mut self, entity: Entity, index: usize)

Implementors§