Skip to main content

Column

Struct Column 

Source
pub struct Column<T> { /* private fields */ }
Expand description

Typed dense column for a single component type within one archetype.

Each row has parallel added_ticks and changed_ticks entries for change detection. Tick 0 is the sentinel meaning “never observed”.

Implementations§

Source§

impl<T: Send + Sync + 'static> Column<T>

Source

pub fn new() -> Self

Create an empty column.

Source

pub fn push(&mut self, value: T)

Append a value at the end with sentinel ticks (0).

Source

pub fn push_with_ticks(&mut self, value: T, added: u64, changed: u64)

Append a value with explicit tick stamps.

Source

pub fn get(&self, row: usize) -> Option<&T>

Get an immutable reference by row index.

Source

pub fn get_mut(&mut self, row: usize) -> Option<&mut T>

Get a mutable reference by row index.

Source

pub fn swap_remove(&mut self, row: usize) -> T

Swap-remove and return the value at row. Tick vectors are kept in sync.

Source

pub fn len(&self) -> usize

Number of rows.

Source

pub fn is_empty(&self) -> bool

Whether the column is empty.

Source

pub fn iter(&self) -> impl Iterator<Item = &T>

Iterate all values immutably.

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>

Iterate all values mutably.

Source

pub fn added_tick(&self, row: usize) -> u64

The added tick for row (0 = sentinel / never stamped).

Source

pub fn changed_tick(&self, row: usize) -> u64

The changed tick for row (0 = sentinel / never stamped).

Source

pub fn set_added_tick(&mut self, row: usize, tick: u64)

Stamp the added tick for row.

Source

pub fn set_changed_tick(&mut self, row: usize, tick: u64)

Stamp the changed tick for row.

Source

pub fn added_ticks(&self) -> &[u64]

Slice of added ticks (parallel to data rows).

Source

pub fn changed_ticks(&self) -> &[u64]

Slice of changed ticks (parallel to data rows).

Trait Implementations§

Source§

impl<T: Send + Sync + 'static> AnyColumn for Column<T>

Source§

fn swap_remove_and_drop(&mut self, row: usize)

Swap-remove a row. The data is dropped.
Source§

fn move_to(&mut self, row: usize, dst: &mut dyn AnyColumn)

Move the data at row in this column into dst (which must be the same concrete Column<T>). The row is swap-removed from self.
Source§

fn len(&self) -> usize

Number of rows.
Source§

fn new_empty(&self) -> Box<dyn AnyColumn>

Create an empty column of the same concrete type.
Source§

fn stamp_ticks(&mut self, row: usize, added: u64, changed: u64)

Stamp both tick vectors at row.
Source§

fn as_any(&self) -> &dyn Any

Source§

fn as_any_mut(&mut self) -> &mut dyn Any

Source§

impl<T: Send + Sync + 'static> Default for Column<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Column<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for Column<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for Column<T>
where Vec<T>: Send,

§

impl<T> Sync for Column<T>
where Vec<T>: Sync,

§

impl<T> Unpin for Column<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for Column<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Column<T>
where Vec<T>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.