Struct sorting_visualization::state::State [−][src]
Contains the state of the whole app.
Fields
time: f64
speed: f64
Speed factor (e.g. 1.0 - normal, 2.0 - 2x faster, 0.5 - 2x slower, etc). Affects the animation time and delays in algorithms.
paused: bool
Is the animation paused?
array: Vec<u32>
An array which is being sorted.
colors: Vec<Color>
Colored overlays of each value. Overlay means that these colors are not used to draw the values, instead they’re drawn over the values. These colors can be used by an algorithm to highlight important array elements.
The length of this vector is equal to the array length, so every color in this vector corresponds to a value with the exact same index.
array_accesses: Vec<f64>
Contains timestamps of the most recent array accesses of every element,
which are drawn like colored overlays. The length of this
vector is equal to the array length, so for every element
in the array only the most recent timestamp is stored
here (not a big deal), so we can avoid memory allocations while program is
running, and this is a pretty simple optimization. To optimize things even
further I’ve done this: if an element hasn’t been accessed yet or it has
been accessed long ago, then instead
of using an Option<f64>
type for every element, I use negative values
because they don’t make any sense in the context of time (this saves
8 bytes
for every element). When an algorithm
reads or writes a
value at a certain index from/to the array, the current
time is stored at exactly the same index in this vector.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnwindSafe for State
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SetParameter for T
[src]
pub fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
[src]
T: Parameter<Self>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,