Professional Documents
Culture Documents
1. Containers :
Container classes’ purpose is to contain
other objects. Each of these classes is a
template, and can be instantiated to contain
any type of object.
The STL container classes include vector,
list, deque, set, multiset, map, multimap,
hash_set, hash_multiset, hash_map and
hash_multimap to suit different kind of tasks.
In associative containers even unordered set,
unordered multiset, unordered map ,
unordered multimap arre included.
2. Iterators:
It is a pointer(kind of) used to manipulate the
elements of the objects’ collections. These
collections may be containers or subsets of
containers.
Iterators provide common interface for any
arbitrary container type. Every container
class provides its own iterator type but when
you try the program examples later, most of
the containers have a common iterator types.
It is a smart pointer.
3. Algorithms:
Algorithms are used to process the elements
of collections. For example, algorithms can
search, sort and modify. Algorithms use
iterators Or simply iterators are link between
containers and algos.
1. Sequence containers
These are ordered collections in which
every element has a certain position i.e.
they store value in contiguous memory
locations.
This position depends on the time and place
of the insertion, but it is independent of the
value of the element.
The STL contains three predefined
sequence container classes: vector, deque,
and list.
Now its types:
a. Vectors:
b. Deque:
The term deque (pronounced “deck”) is an
abbreviation for ‘double-ended queue’.
It is a dynamic array that is implemented so
that it can grow in both directions.
So, inserting elements at the end and at the
beginning is fast. However, inserting
elements in the middle takes time because
elements must be moved.
c. List:
List is simply a doubly linked list.
Elements are not stored in contiguous
memory locations.
List does not support random access(i.e.
elements cannot be accessed like arrays as
arr[5]).
2. Associative Containers:
These are sorted collections in which the
actual position of an element depends on
its value due to a certain sorting criterion.
We have no idea of a sequence.
Data is accessed using the key instead of
indexes.
Stream Classes:
Stream classes in C++ are used to input and
output operations on files and io devices.
These classes have specific features and to
handle input and output of the program.
There are three classes of iostream library: