linked list visualisations
This commit is contained in:
@@ -77,6 +77,11 @@ export interface DataState {
|
||||
pointers: PointerState[];
|
||||
variables: VariableState[];
|
||||
calculations: CalculationState[];
|
||||
// LinkedList support
|
||||
linkedLists?: LinkedListState[];
|
||||
linkedListPointers?: LinkedListPointerState[];
|
||||
// Stack support
|
||||
stacks?: StackState[];
|
||||
}
|
||||
|
||||
/** Single step in the visualization */
|
||||
@@ -152,3 +157,49 @@ export interface UseVisualizationReturn {
|
||||
currentPhase: VisualizationPhase;
|
||||
progress: number;
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// LinkedList Types
|
||||
// ============================================
|
||||
|
||||
/** State of a linked list node */
|
||||
export interface LinkedListNodeState {
|
||||
id: string;
|
||||
value: number;
|
||||
index: number;
|
||||
state: 'normal' | 'highlighted' | 'dimmed' | 'success' | 'comparing';
|
||||
isNull?: boolean;
|
||||
}
|
||||
|
||||
/** Complete linked list state */
|
||||
export interface LinkedListState {
|
||||
id: string;
|
||||
nodes: LinkedListNodeState[];
|
||||
label?: string;
|
||||
}
|
||||
|
||||
/** Pointer for linked list visualization */
|
||||
export interface LinkedListPointerState {
|
||||
id: string;
|
||||
name: string;
|
||||
nodeIndex: number;
|
||||
color: 'slow' | 'fast' | 'prev' | 'curr' | 'next' | 'default';
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// Stack Types
|
||||
// ============================================
|
||||
|
||||
/** State of a stack element */
|
||||
export interface StackElementState {
|
||||
id: string;
|
||||
value: number | string;
|
||||
state: 'normal' | 'highlighted' | 'popped' | 'pushing';
|
||||
}
|
||||
|
||||
/** Complete stack state */
|
||||
export interface StackState {
|
||||
id: string;
|
||||
elements: StackElementState[];
|
||||
label?: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user