Lecture21 - Buffer: Vector vs Stack Admin Todays topics !...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Admin Today’s topics Finish Editor Buffer case study Start Map implementation, trees Reading Ch 9 Ch 13 Café today after class Lecture #21 Buffer: Vector vs Stack Vector Stack Buffer() O(1) O(1) ~Buffer() O(1) O(1) moveCursorForward() O(1) O(1) moveCursorBackward() O(1) O(1) moveCursorToStart() O(1) O(N) moveCursorToEnd() O(1) O(N) insertCharacter() O(N) O(1) deleteCharacter() O(N) O(1) Space used 1N 2N Buffer as linked list Inspiration: contiguous memory is constraining Connect chars without locality Linked list to the rescue! Buffer contains: AB | CDE // for Buffer class private: struct cellT { char ch; cellT *next; }; cellT *head, *cursor; head cursor E A A B C C D Cursor design Where does cursor point? To cell before or after ? After E? Before A? 5 letters, 6 cursor positions… head cursor E A A B C C D
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Use of dummy cell for linked list Add "dummy cell" to front of list SimpliFes logic Every cell holding actual data has a predecessor
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/12/2011 for the course CS 108 taught by Professor Smith during the Spring '11 term at Central Mich..

Page1 / 4

Lecture21 - Buffer: Vector vs Stack Admin Todays topics !...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online