Chapter 5: Vectors, Lists, and Sequences

5.1 Vectors

5.1.1 The Vector Abstract Data Type
Vectors.pdf 1-2-3-4
A linear sequence that supports access to its elements by their ranks is called a vector.

5.1.2 A Simple Array-Based Implementation
Vectors.pdf 5-6-7-8

5.1.3 An Extendable Array Implementation

html-5.2
html-5.3
Fixed Length Capacity Increment

5.1.4 The STL vector Class


5.2 Lists

5.2.1 Node-Based Operations and Positions
Sequences.pdf 1-2-3-4-5

Positions
Sequences.pdf 6
We view a list as a container of elements that stores each element at a positions arranged in a linear order.

5.2.2 The List Abstract Data Type

Sequences.pdf 7
html-5.4

5.2.3 Doubly Linked List Implementation

Sequences.pdf 8
html-5.5 (Node)

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

Insertion
Sequences.pdf 9

Deletion
Sequences.pdf 10
html-5.10 (NodeList1)
html-5.11 (NodeList2)

5.2.4 The STL list Class
list<>
size()
empty()
front()
back()
push_front(e)
push_back(e)
pop_front()
pop_back()

Similarities and Differences with Our List ADT


5.3 Sequences

5.3.1 The Sequence Abstract Data Type
Sequences.pdf 12-13

Multiple Inheritance in the Sequence ADT
html-5.12 (Sequence)

5.3.2 Implementing a Sequence with a Doubly Linked List
html-5.13 (NodeSequence1)
html-5.14 (NodeSequence2)

5.3.3 Implementing a Sequence with an Array

Sequences.pdf 14

5.3.4 Comparing Sequence Implementations

Sequences.pdf 15


5.4 Case Study: Bubble-Sort on a Sequence

5.4.1 The Bubble-Sort Algorithm
html-5.15

5.4.2 A Sequence-Based Analysis of Bubble-Sort


5.5 Iterators

An iterator consists of a sequence S, a current position in S, and a way of stepping to the next position in S and making it the current position.

5.5.1 Iterator Functions
Sequences.pdf 16
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