Standard Template Library( STL ) in C++

The Standard Template Library, STL for short, adds enormous power to the C++ programmers. Efficiency in programming has been of prime importance since we started using computer as to produce business-level solutions. As a result, the search for more and more efficient data structures continued, and the sooner the programmer adapted an efficient data structure in his solution, the better. In the early programming languages, like C, solutions were possible only in the "structured" way, or I should rather use the words "structured programming" for this purpose.

Structured programming makes use of global functions to break the main problem into subproblems, and calling the required function with proper arguments. Though this seemed to be a quite clean way to deal with small programs, the size and complexity of the programs that we have to deal today demands a far more efficient solution, one that optimizes labor, as well as ensures code reusability. The overall gain demanded was that of reducing the cost of maintaining the difficult-to-deal-with structured code. This is where the need of object oriented programming was felt.

Object oriented programming uses the concept of modelling everything as an object, which may have some attributes ( properties, like the object "human" has properties : black hair, 2 hands, etc... ) and may perform some activity or function ( like the human takes food ). This way, enormous effort can be saved if we just create the required object when necessary, and make it do whatever we need to do then.
The Standard Template Library provides an Object Oriented implementation of the most commonly used data structures and algorithms used for every field of programming. The most commonly used ( as far as personal experience goes ) structures from STL are

  • Queue
  • Stack
  • Vector
  • List
  • Priority Queue
  • Set, Multiset
  • Map, Multimap
  • Bitset
  • Pair

There are also some algorithm functions already hard-coded in STL. So far, I have found the "sort" function very useful. There are many other generic ( template ) functions too, which is better learnt through a STL documentation, for example, at sgi ( http://www.sgi.com ).
From here on, I will publish the contents of each topic in seperate posts titled by the topic name to make things neat.



Posted bysamir at 1:32 AM  

0 comments:

Post a Comment