Sunday, May 10, 2009

STANDARD TEMPLATE LIBRARY

At the core of the standard template library are three foundational items:
1. Containers,
2. Algorithms ,
3. Iterators


These items work in conjunction with one another to provide off-the-shelf solutions to a variety of programming problems

Containers

Containers are objects that hold other objects, and there are several different types. For example,

The vector class defines a dynamic array,

Deque creates a double-ended queue, and

List provides a linear list.

These containers are called sequence containers because in STL terminology, a sequence is a linear list.

The STL also defines associative containers, which allow efficient retrieval of values based on keys.
For example,
a map provides access to values with unique keys.

Thus, a map stores a key/value pair and allows a value to be retrieved given its key.

Each container class defines a set of functions that may be applied to the container.
For example, a list container includes functions that insert, delete, and merge elements.

Algorithms

Algorithms act on containers. They provide the means by which you will manipulate the contents of containers. Their capabilities include initialization, sorting, searching, and transforming the contents of containers.

Iterators

Iterators are objects that are, more or less, pointers.
There are five types of iterators:
Iterator Access Allowed
1. Random Access Store and retrieve values.
Elements may be accessed randomly.
2. Bidirectional Store and retrieve values.
Forward and backward moving.
3. Forward Store and retrieve values.
Forward moving only.
4. Input Retrieve, but not store values.
Forward moving only.
5. Output Store, but not retrieve values.
Forward moving only.

Iterators are handled just like pointers. You can increment and decrement them. Iterators are declared using the iterator type
defined by the various containers.

No comments:

Post a Comment