This Skillable lab activity requires you to implement an advanced text editor that uses linked lists to manage text lines, cursor movement, and undo/redo functionality.
- Implement a doubly linked list for text lines with bidirectional navigation
- Create a circular linked list for undo/redo history management
- Apply optimization techniques (size tracking, tail pointers)
- Handle complex edge cases in linked list operations
You're building an advanced text editor that needs to support:
- Cursor movement (forward/backward through text lines)
- Undo/redo functionality with circular history
- Efficient text manipulation operations
The system requires:
- A doubly linked list for text lines with bidirectional navigation
- A circular linked list for undo/redo history management
- Optimization for performance
- Handling of complex edge cases
src/main/java/com/jse/texteditor/
├── TextLineNode.java # Node class for doubly linked list
├── TextEditor.java # Main editor class
├── HistoryNode.java # Node class for circular history list
└── EditorState.java # State class for undo/redo
src/test/java/com/jse/texteditor/
└── TextEditorTest.java # Test cases
String text- The text content of the lineTextLineNode next- Reference to next nodeTextLineNode previous- Reference to previous node- Constructor to initialize with text
- Use doubly linked list to store text lines
- Maintain head, tail, and current cursor position
- Implement the following methods:
insertLine(String text)- Insert a new line at cursor positiondeleteLine()- Delete line at cursor positionmoveCursorForward()- Move cursor to next linemoveCursorBackward()- Move cursor to previous linegetCurrentLine()- Get text at cursor positiongetLineCount()- Get total number of lines (O(1) using size tracking)getAllLines()- Get all lines as a list
- Implement circular linked list for undo/redo history
- Each HistoryNode stores an EditorState snapshot
- Implement:
undo()- Restore previous editor stateredo()- Restore next editor state (if available)saveState()- Save current state to history
- Size tracking for O(1) line count operations
- Tail pointer maintenance for efficient append operations
- Efficient cursor movement using bidirectional traversal
- Empty document (no lines)
- Single line document
- Cursor at boundaries (beginning/end)
- History overflow (circular wrap)
- Null references
- Design the data structures - Plan TextLineNode, HistoryNode, and TextEditor classes
- Implement doubly linked list - Create TextLineNode and basic TextEditor structure
- Implement cursor movement - Add bidirectional traversal methods
- Implement circular history - Create HistoryNode and circular list structure
- Implement undo/redo - Add state management and navigation
- Add optimizations - Implement size tracking and tail pointers
- Handle edge cases - Test and fix boundary conditions
- Test and debug - Run test cases and optimize performance
Run the provided test cases:
mvn test- Starter code framework provided
- Test cases for validation
- Performance benchmarks included