linked list visualisations

This commit is contained in:
2025-08-24 16:33:51 +01:00
parent 68e5e95dda
commit 1851072d80
12 changed files with 1272 additions and 6 deletions

View File

@@ -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;
}