Chapter 5: Vectors, Lists, and Sequences

5.1 Vectors

5.1.1 The Vector Abstract Data Type
5.1.2 A Simple Array-Based Implementation


Insertion


Deletion


Performance
5.1.3 An Extendable Array Implementation
html-5.2
html-5.3
Fixed Length Capacity Increment


5.2 Lists

5.2.1 Node-Based Operations and Positions

Position ADT
5.2.2 The List Abstract Data Type
html-5.4

5.2.3 Doubly Linked List Implementation


html-5.5 (Node)



Using Positions
html-5.6 (Positions)
html-5.7 (InvalidPositionException)

Insertion
We visualize operation insertAfter(p, X), which returns position q

Deletion
We visualize remove(p), where p = last()

html-5.10 (NodeList1)
html-5.11 (NodeList2)

Performance

5.3 Sequences

5.3.1 The Sequence Abstract Data Type
Multiple Inheritance in the Sequence ADT
html-5.12 (Sequence)

5.3.2 Implementing a Sequence with a Doubly Linked List
All of the functions of the list ADT can be easily implemented to run O(1) time.

html-5.13 (NodeSequence1)
html-5.14 (NodeSequence2)

5.3.3 Implementing a Sequence with an Array




5.3.4 Comparing Sequence Implementations


Operation
Array
List
size, isEmpty
1
1
atRank, rankOf, elemAtRank
1
n
first, last, before, after
1
1
replaceElement, swapElements
1
1
replaceAtRank
1
n
insertAtRank, removeAtRank
n
n
insertFirst, insertLast
1
1
insertAfter, insertBefore
n
1
remove
n
1


5.5 Iterators

5.5.1 Iterator Functions
html-16 (ObjectIterator)

STL Iterators
html-17 (STLiterator)


5.6 A Hierarchy of Sequence ADTs

5.6.1 Functions of a Container
A container is a data structure that stores and organizes a collection of objects, called the elements of the container, and provides access to them through the functions of an abstract data type.

The Container ADT
The functions of a container:
5.6.2 Inspectable Containers
Containers that do not provide update functions are called inspectable containers.

5.6.3 Inheritance Structure of Sequence ADTs

InspectableSequence.cpp