Trait OrderedRelationshipSourceCollection

Source
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§

Source

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.

Source

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

Removes the entity at the specified idnex if it exists.

Source

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.

Source

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

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

Source

fn sort(&mut self)

Sorts the source collection.

Source

fn insert_sorted(&mut self, entity: Entity)

Inserts the entity at the proper place to maintain sorting.

Source

fn place_most_recent(&mut self, index: usize)

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

Source

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§

Source

fn push_front(&mut self, entity: Entity)

Adds the entity at index 0.

Source

fn push_back(&mut self, entity: Entity)

Adds the entity to the back of the collection.

Source

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

Removes the first entity.

Source

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§

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn sort(&mut self)

Source§

fn insert_sorted(&mut self, entity: Entity)

Source§

fn place_most_recent(&mut self, index: usize)

Source§

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

Implementors§