Friday, June 8, 2012

STL

STL базируется на containers, algorithms, iterators.

Containers - объекты, которые содержат другие объекты.
Examples:
Sequence containers: vector, deque, list
Associative containers(based on keys): map

Each container class defines a set of functions that may be applied to the container.

Algorithms act on containers. (initialization, sorting, searching and transforming the contents of containers).

Iterators are objects that act, more or less, like pointers. They give you the ability to cycle through the contents of a container in much the same way that you would use a pointer to cycle through an array.

Есть 5 типов итераторов:

Random Access - Store and retrieve values. Elements may be accessed randomly.
Bidirectional - Store and retrieve values. Forward and backward moving.
Forward - Store and retrieve values. Forward moving only.
Input - Retrieve, but not store values. Forward moving only.
Output - Store, but not retrieve values. Forward moving only.


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

The STL also supports reverse iterators. Reverse iterators are either bidirectional or
random-access iterators that move through a sequence in the reverse direction. Thus, if
a reverse iterator points to the end of a sequence, incrementing that iterator will cause
it to point to one element before the end.


Term    Represents
BiIter - Bidirectional iterator
ForIter - Forward iterator
InIter  - Input iterator
OutIter - Output iterator
RandIter - Random access iterator



No comments:

Post a Comment