DisplayMode

Struct DisplayMode 

Source
pub struct DisplayMode {
    pub viewed_algorithm: AlgorithmType,
    pub available_algorithms: Vec<AlgorithmType>,
    pub cycle_index: usize,
    /* private fields */
}
Expand description

Controls which algorithm’s array visualization is shown

Fields§

§viewed_algorithm: AlgorithmType

Currently viewed algorithm

§available_algorithms: Vec<AlgorithmType>

Available algorithms in current race

§cycle_index: usize

Current index in the available algorithms list

Implementations§

Source§

impl DisplayMode

Source

pub fn new() -> Self

Create a new display mode

Source

pub fn with_algorithms(algorithms: Vec<AlgorithmType>) -> Result<Self>

Create display mode with specific algorithm set

Source

pub fn handle_visualization_switch( &mut self, _key_event: KeyEvent, ) -> Result<()>

Handle visualization switch key event

Source

pub fn cycle_to_next_algorithm(&mut self)

Cycle to the next algorithm

Source

pub fn set_viewed_algorithm( &mut self, algorithm_type: AlgorithmType, ) -> Result<()>

Set viewed algorithm by type

Source

pub fn set_viewed_algorithm_by_index(&mut self, index: usize) -> Result<()>

Set viewed algorithm by index

Source

pub fn should_update_visualization(&self) -> bool

Check if visualization should be updated

Source

pub fn mark_visualization_updated(&mut self)

Mark visualization as updated

Source

pub fn get_current_array_data<'a>( &self, algorithms: &'a [Box<dyn Sorter>], ) -> Option<&'a [i32]>

Get current array data from algorithm instances

Source

pub fn get_array_source_algorithm(&self) -> String

Get array source algorithm name

Source

pub fn get_highlighted_algorithm(&self) -> AlgorithmType

Get currently highlighted algorithm

Source

pub fn is_algorithm_highlighted(&self, algorithm_type: AlgorithmType) -> bool

Check if specific algorithm is highlighted

Source

pub fn get_current_algorithm_index(&self) -> usize

Get current algorithm index

Source

pub fn get_algorithm_count(&self) -> usize

Get total number of available algorithms

Source

pub fn update_available_algorithms( &mut self, algorithms: Vec<AlgorithmType>, ) -> Result<()>

Update available algorithms (e.g., when some algorithms fail)

Source

pub fn reset_to_first(&mut self)

Reset to first algorithm

Source

pub fn get_algorithm_at_index(&self, index: usize) -> Option<AlgorithmType>

Get algorithm at specific index

Source

pub fn can_cycle_next(&self) -> bool

Check if we can cycle to next algorithm

Source

pub fn peek_next_algorithm(&self) -> Option<AlgorithmType>

Get next algorithm in cycle (without changing current)

Source

pub fn peek_previous_algorithm(&self) -> Option<AlgorithmType>

Get previous algorithm in cycle (without changing current)

Source

pub fn from_algorithms(algorithms: &[Box<dyn Sorter>]) -> Self

Create display mode from algorithm instances

Source

pub fn process_key_event(&mut self, key_event: KeyEvent) -> Result<bool>

Process visualization key event

Trait Implementations§

Source§

impl Clone for DisplayMode

Source§

fn clone(&self) -> DisplayMode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DisplayMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DisplayMode

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V