

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Different implementations of a buffer for text editors, including stack and queue, using vector, stack, and linked list. It includes the command-line text editing commands, buffer requirements, and the interface for the buffer class.
Typology: Lecture notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


! F! Move cursor forward one character position! ! B! Move cursor backward one character position ! J! Jump to start of buffer (before first character) ! E! Move cursor to end of buffer (after last character)! ! Ixxx Insert characters xxx at current cursor position ! D! Delete character after current cursor position
class Buffer { public: Buffer(); ~Buffer(); void moveCursorForward(); void moveCursorBackward(); void moveCursorToStart(); void moveCursorToEnd(); void insertCharacter(char ch); void deleteCharacter(); void display(); private: // TBD! };
// for Buffer class private: Vector
Evaluate Vector Buffer Buffer() O(1) ~Buffer() O(1) moveCursorForward() O(1) moveCursorBackward() O(1) moveCursorToStart() O(1) moveCursorToEnd() O(1) insertCharacter() O(N) deleteCharacter() O(N) Space used ~1 byte per char Buffer layered on Stack Inspiration: add/remove at end of vector is fast