Monday, October 31, 2011

standard template library

standard template library c++

The Standard Template Library – STL provides a set of C++ container classes and template algorithms designed to work together to produce a wide range of useful functionality. Though only a small number of container classes are provided, they include the most widely useful containers, such as vectors, lists, sets and maps. The template algorithm components include a broad range of fundamental algorithms for the most common kinds of data manipulations, such as searching, sorting, and merging.

The critical difference between STL and all other C++ container class libraries is that STL algorithms are generic: every algorithm works on a variety of containers, including built-in types, and many work on all containers. Initially we will look at why and how of generic algorithms and other key concepts that give STL many advantages over other software libraries. One of the most important concepts of STL is the way generic algorithms are defined in terms of iterators, which generalize C/C++ pointers, together with the way different kinds of iterators are defined for traversing the different kind of containers.  Beside containers, generic algorithms, and iterators, STL also provides function objects which generalize ordinary C/C++ functions and allow other components to be efficiently adapted to a variety of tasks. The library also includes various other kinds of adapters for changing the interfaces of containers, iterators, or functions objects. Storage management in STL is controlled by yet another component type, allocators. All these components are discussed in the STL overview in my coming posts.

STL is only part of a large software library, the C++ standard library approved by the ANSI/ISO C++ committee in the International Standard for C++. Nevertheless, STL remains a coherent framework of fine-grained, interchangeable components that deserve treatment separate from the rest of the C++ Standard Library.

Following topic are under STL,

1. About STL

2. make_pair in stl

3. Containers
   a. Sequence Container
      a1. vector
      a2. deque
      a3. list
   b. Associative Container
   c. container adaptors

4. Iterators 
   a. Examples of Using Associative Containers
      a1. Examples of Using Sets & Multisets
      a2. Examples of Using Map & Multimaps
      a3. Maps as Associative Arrays
   b. Iterator Category
      b1. Bidirectional Operator
      b2. Random Access Operator

5. Algorithm
   a. STL Ranges

6. Iterator Adapters
   a. Insert iterators
   b. Stream iterators
   c. Reverse iterators

7. Manipulating Algorithm
   a. Removing Elements

8. Functions as Algorithm Arguments
   a. Examples of using Functions as Algorithm Arguments
   b. predicates
      b1. unary predicate
      b2. binary predicate

9. Function Objects 
   a. What are Function Objects
   b. Advantage of Function Objects
   c. Predefined Function Objects

10. Container Elements
   a. Requirements for container elements
   b. Value semantics or Reference Semantics

11. Errors and Exceptions Inside the STL
   a. Error Handling
   b. Exception Handling

12. STL Containers

   a. Common Container Abilities and Operations
     a1. Common Container Abilities
     a2. Common Container Operations

   b. Vectors
     b1. Abilities of Vectors
     b2. Vector Operations
     b3. Using Vectors as Ordinary Arrays
     b4. Examples of Using Vectors
     b5. Class vector<bool>

   c. Deques
     c1. Abilities of Deques
     c2. Deque Operation
     c3. Example of Using Deque

  d.  Lists
     d1. Advantage of Lists
     d2. List Operations
     d3. Example using List

 STL Sample Codes

  1. vector
  2. deque
  3. list
  4. Iterators 
  5. set
  6. multiset
  7. map
  8. multimap
  9. Maps as Associative Arrays
  10. insert iterator
  11. stream iterator
  12. reverse iterator
  13. list remove  
  14. for_each
  15. transform algorithm
  16. find_if example (unary predicate)
  17. binary predicate
  18. using function object
  19. predefined function objects
         Reference Books for C++ Standard Template Library

    No comments:

    Post a Comment