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
impl DisplayMode
Sourcepub fn with_algorithms(algorithms: Vec<AlgorithmType>) -> Result<Self>
pub fn with_algorithms(algorithms: Vec<AlgorithmType>) -> Result<Self>
Create display mode with specific algorithm set
Sourcepub fn handle_visualization_switch(
&mut self,
_key_event: KeyEvent,
) -> Result<()>
pub fn handle_visualization_switch( &mut self, _key_event: KeyEvent, ) -> Result<()>
Handle visualization switch key event
Sourcepub fn cycle_to_next_algorithm(&mut self)
pub fn cycle_to_next_algorithm(&mut self)
Cycle to the next algorithm
Sourcepub fn set_viewed_algorithm(
&mut self,
algorithm_type: AlgorithmType,
) -> Result<()>
pub fn set_viewed_algorithm( &mut self, algorithm_type: AlgorithmType, ) -> Result<()>
Set viewed algorithm by type
Sourcepub fn set_viewed_algorithm_by_index(&mut self, index: usize) -> Result<()>
pub fn set_viewed_algorithm_by_index(&mut self, index: usize) -> Result<()>
Set viewed algorithm by index
Sourcepub fn should_update_visualization(&self) -> bool
pub fn should_update_visualization(&self) -> bool
Check if visualization should be updated
Sourcepub fn mark_visualization_updated(&mut self)
pub fn mark_visualization_updated(&mut self)
Mark visualization as updated
Sourcepub fn get_current_array_data<'a>(
&self,
algorithms: &'a [Box<dyn Sorter>],
) -> Option<&'a [i32]>
pub fn get_current_array_data<'a>( &self, algorithms: &'a [Box<dyn Sorter>], ) -> Option<&'a [i32]>
Get current array data from algorithm instances
Sourcepub fn get_array_source_algorithm(&self) -> String
pub fn get_array_source_algorithm(&self) -> String
Get array source algorithm name
Sourcepub fn get_highlighted_algorithm(&self) -> AlgorithmType
pub fn get_highlighted_algorithm(&self) -> AlgorithmType
Get currently highlighted algorithm
Sourcepub fn is_algorithm_highlighted(&self, algorithm_type: AlgorithmType) -> bool
pub fn is_algorithm_highlighted(&self, algorithm_type: AlgorithmType) -> bool
Check if specific algorithm is highlighted
Sourcepub fn get_current_algorithm_index(&self) -> usize
pub fn get_current_algorithm_index(&self) -> usize
Get current algorithm index
Sourcepub fn get_algorithm_count(&self) -> usize
pub fn get_algorithm_count(&self) -> usize
Get total number of available algorithms
Sourcepub fn update_available_algorithms(
&mut self,
algorithms: Vec<AlgorithmType>,
) -> Result<()>
pub fn update_available_algorithms( &mut self, algorithms: Vec<AlgorithmType>, ) -> Result<()>
Update available algorithms (e.g., when some algorithms fail)
Sourcepub fn reset_to_first(&mut self)
pub fn reset_to_first(&mut self)
Reset to first algorithm
Sourcepub fn get_algorithm_at_index(&self, index: usize) -> Option<AlgorithmType>
pub fn get_algorithm_at_index(&self, index: usize) -> Option<AlgorithmType>
Get algorithm at specific index
Sourcepub fn can_cycle_next(&self) -> bool
pub fn can_cycle_next(&self) -> bool
Check if we can cycle to next algorithm
Sourcepub fn peek_next_algorithm(&self) -> Option<AlgorithmType>
pub fn peek_next_algorithm(&self) -> Option<AlgorithmType>
Get next algorithm in cycle (without changing current)
Sourcepub fn peek_previous_algorithm(&self) -> Option<AlgorithmType>
pub fn peek_previous_algorithm(&self) -> Option<AlgorithmType>
Get previous algorithm in cycle (without changing current)
Sourcepub fn from_algorithms(algorithms: &[Box<dyn Sorter>]) -> Self
pub fn from_algorithms(algorithms: &[Box<dyn Sorter>]) -> Self
Create display mode from algorithm instances
Sourcepub fn process_key_event(&mut self, key_event: KeyEvent) -> Result<bool>
pub fn process_key_event(&mut self, key_event: KeyEvent) -> Result<bool>
Process visualization key event
Trait Implementations§
Source§impl Clone for DisplayMode
impl Clone for DisplayMode
Source§fn clone(&self) -> DisplayMode
fn clone(&self) -> DisplayMode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for DisplayMode
impl Debug for DisplayMode
Auto Trait Implementations§
impl Freeze for DisplayMode
impl RefUnwindSafe for DisplayMode
impl Send for DisplayMode
impl Sync for DisplayMode
impl Unpin for DisplayMode
impl UnwindSafe for DisplayMode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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