3 A STL overview


STL is a component library. This means that it consists of components - clean and formally sound concepts. Such components are for example containers - that are objects which store objects of an arbitrary type - and algorithms. Because of the generic approach STL algorithms are able to work on user-built containers and user-built algorithms can work on STL containers - if the user takes some strict requirements for building his components into consideration. This technique - to guarantee the interoperability between all built-in and user-built components - is referred to as "the orthogonal decomposition of the component space". The idea behind STL can easily be shown by the following consideration:

Imagine software components as a three-dimensional space. One dimension represents the data types (int, double, char, ...), the second dimension represents the containers (array, linked-list, ...) and the third dimension represents the algorithms (sort, merge, search, ...).


Figure 1: Component space


With this scenario given, i*j*k different versions of code have to be designed - a sort algorithm for an array of int, the same sort algorithm for an array of double, a search algorithm for a linked-list of double and so on. By using template functions that are parametrized by a data type, the i-axes can be dropped and only j*k versions of code have to be designed, because there has to be only one linked-list implementation which then can hold objects of any data-type. The next step is to make the algorithms work on different containers - that means that a search algorithm should work on arrays as well as on linked-lists, etc. Then, only j+k versions of code have to be created.

STL embodies the above concept and is thus expected to simplify software development by decreasing development times, simplifying debugging and maintenance and increasing the portability of code.

STL consists of five main components. When I list them here, don't get confused by the names and their short description, they are explained one by one in detail later.

At this point I recommend to read [2], chapters 1 to 4.

Continue with section 3.1.1

Back to index


Johannes Weidl (J.Weidl@infosys.tuwien.ac.at) - Apr 16, 1996