FACTOID # 15: Most people live in poverty in most African countries.
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

FACTS & STATISTICS    Simple view

  1. Select countries to view: (hold down Control key and click to select several)

     

     

    Compare:

     

     

  1. Select fact or statistic: (* = graphable)

     

     

     

  2. (OPTIONAL) Compare to statistic: (both need to be graphable)

     

     

     

  3. View result as:

     

       
(OR) SEARCH ALL encyclopedia, stats & forums:   

Encyclopedia > Standard Template Library

The Standard Template Library (STL) is a software library partially included in the C++ Standard Library. It provides containers, iterators, algorithms, and functors. More specifically, the C++ Standard Library is based on the STL published by SGI. Both include some features not found in the other. SGI's STL is rigidly specified as a set of headers, while ISO C++ does not specify header content, and allows implementation either in the headers, or in a true library. Illustration of an application which may use libvorbisfile. ... C++ (pronounced ) is a general-purpose programming language. ... In C++, the Standard Library is a collection of classes and functions, which are written in the core language. ... A container is a type of data structure. ... In computer science, an iterator is an object which allows a programmer to traverse through all the elements of a collection, regardless of its specific implementation. ... Flowcharts are often used to graphically represent algorithms. ... A function object, often called a functor or functionoid, is a computer programming construct allowing an object to be invoked or called as if it were an ordinary function, usually with the same syntax. ... Silicon Graphics, Inc. ... In computer programming, particularly in the C and C++ programming languages, a header file or include file is a file, usually in the form of source code, that is automatically included in another source file by the compiler. ...

Contents

Overview

The STL provides a ready-made set of common classes for C++, such as containers and associative arrays, that can be used with any built-in type and with any user-defined type that supports some elementary operations (such as copying and assignment). STL algorithms are independent of containers, which significantly reduces the complexity of the library. C++ (pronounced ) is a general-purpose programming language. ... A container is a type of data structure. ... An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. ... A container is a type of data structure. ...


The STL achieves its results through the use of templates. This approach provides compile-time polymorphism that is often more efficient than traditional run-time polymorphism. Modern C++ compilers are tuned to minimize any abstraction penalty arising from heavy use of the STL. In computer programming, templates are a feature of the C++ programming language that allow code to be written without consideration of the data type with which it will eventually be used. ... The Greek meaning of the words poly and morph together imply that a single entity can take on multiple forms. In the field of computer science, there are two fundamentally different types of polymorphism; subtype polymorphism, and parametric polymorphism. ... In simple terms, polymorphism lets you treat derived class members just like their parent class members. ... C++ (pronounced ) is a general-purpose programming language. ... A diagram of the operation of a typical multi-language, multi-target compiler. ...


The STL was created as the first library of generic algorithms and data structures for C++, with four ideas in mind: generic programming, abstractness without loss of efficiency, the Von Neumann computation model, and value semantics. C++ (pronounced ) is a general-purpose programming language. ... Generic programming is a style of computer programming where algorithms are written in an extended grammar and are made adaptable by specifying variable parts that are then somehow instantiated later by the compiler with respect to the base grammar. ... In computer science, abstraction is a mechanism and practice to reduce and factor out details so that one can focus on a few concepts at a time. ... Design of the Von Neumann architecture For the robotic architecture also named after Von Neumann, see Von Neumann machine The von Neumann architecture is a computer design model that uses a single storage structure to hold both instructions and data. ...


Contents

Containers

The STL contains sequence containers and associative containers. The standard sequence containers include vector, deque and list. The standard associative containers are set, multiset, map and multimap. A container is a type of data structure. ... A container is a type of data structure. ... Look up list in Wiktionary, the free dictionary. ... An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. ...

Container Description
Sequences (Arrays / Linked Lists) - ordered collections
vector a dynamic array, like C array (i.e., capable of random access) with the ability to automatically resize itself when inserting or erasing an object. Inserting and removing an element to/from back of the vector at the end takes amortized constant time. Inserting and erasing at the beginning or in the middle is linear in time.

A specialization for type bool exists, which optimizes for space by storing bool values as bits. Look up list in Wiktionary, the free dictionary. ... For the microarray in genetics, see SNP array. ... In computer science, a linked list is one of the fundamental data structures, and can be used to implement other data structures. ... Vector (or std::vector) is a C++ implementation of the dynamic array data structure. ... A dynamic array, growable array, resizable array, dynamic table, or array list is a data structure, an array which is automatically expanded to accommodate new objects if filled beyond its current size. ... C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... For the microarray in genetics, see SNP array. ... In computer science, random access is the ability to access a random element of a group in equal time. ... In computational complexity theory, amortized analysis is the time per operation averaged over a worst_case sequence of operations. ... In computer science, the boolean datatype, sometimes called the logical datatype is a primitive datatype having two values, true and false. ... In computer science, the boolean datatype, sometimes called the logical datatype is a primitive datatype having two values, true and false. ...

list a doubly-linked list; elements are not stored in contiguous memory. Opposite performance from a vector. Slow lookup and access (linear time), but once a position has been found, quick insertion and deletion (constant time).
deque (double ended queue) a vector with insertion/erase at the beginning or end in amortized constant time, however lacking some guarantees on iterator validity after altering the deque.
Associative containers - unordered collections
set a sorted set; inserting/erasing elements in a set does not invalidate iterators pointing in the set. Provides set operations union, intersection, difference, symmetric difference and test of inclusion. Type of data must implement comparison operator < or custom comparator function must be specified. Implemented using a self-balancing binary search tree.
multiset same as a set, but allows duplicate elements.
map a sorted associative array; allows mapping from one data item (a key) to another (a value). Type of key must implement comparison operator < or custom comparator function must be specified. Implemented using a self-balancing binary search tree.
multimap same as a map, but allows duplicate keys.
hash_set

hash_multiset
hash_map
hash_multimap In computer science, a linked list is one of the fundamental data structures used in computer programming. ... In computer science, a linked list is one of the fundamental data structures, and can be used to implement other data structures. ... In computer science, a deque (short for double-ended queue) is a data structure for which elements can be added to or removed from the front or back. ... A queue (pronounced /kuː/) is a particular kind of collection in which the entities in the collection are kept in order and the principal (or only) operations on the collection are the addition of entities to the rear terminal position and removal of entities from the front terminal position. ... An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. ... In computer science, the set is a collection of certain values without any particular order. ... In set theory and other branches of mathematics, the union of a collection of sets is the set that contains everything that belongs to any of the sets, but nothing else. ... In mathematics, the intersection of two sets A and B is the set that contains all elements of A that also belong to B (or equivalently, all elements of B that also belong to A), but no other elements. ... In set theory and other branches of mathematics, two kinds of complements are defined, the relative complement and the absolute complement. ... In mathematics, the symmetric difference of two sets is the set of elements which are in one of either set, but not in both. ... In computing, a self-balancing binary search tree or height-balanced binary search tree is a binary search tree that attempts to keep its height, or the number of levels of nodes beneath the root, as small as possible at all times, automatically. ... In programming: Map <Key, Data, Compare, Alloc> is a C++ container. ... An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. ...

similar to a set, multiset, map, or multimap, respectively, but implemented using a hash table; keys are not sorted, but a hash function must exist for key type. These containers are not part of the C++ Standard Library, but are included in SGI's STL extensions, and are included in common libraries such as the GNU C++ Library in the __gnu_cxx namespace. These are scheduled to be added to the C++ standard as part of TR1, with the slightly different names of unordered_set, unordered_multiset, unordered_map and unordered_multimap.
Other types of containers
bitset stores series of bits similar to a fixed-sized vector of bools. Also optimizes for space
valarray another C-like array like vector, but is designed for high speed numerics at the expense of some programming ease and general purpose use. It has many features that make it ideally suited for use with vector processors in traditional vector supercomputers and SIMD units in consumer-level scalar processors, and also ease vector mathematics programming even in scalar computers.

In computer science, a hash table is a data structure that speeds up searching for information by a particular aspect of that information, called a key. ... A hash function is a reproducible method of turning some kind of data into a (relatively) small number that may serve as a digital fingerprint of the data. ... A container is a type of data structure. ... Technical Report 1 (TR1) is a draft document specifying additions to the C++ Standard Library such as regular expressions, smart pointers, hash tables, and random number generators. ... For the microarray in genetics, see SNP array. ...

Iterators

The STL implements five different types of iterators. These are input iterators (which can only be used to read a sequence of values), output iterators (which can only be used to write a sequence of values), forward iterators (which can be read, written to, and move forward), bidirectional iterators (which are like forward iterators but can also move backwards) and random access iterators (which can move freely any number of steps in one operation). In computer science, an iterator is an object which allows a programmer to traverse through all the elements of a collection, regardless of its specific implementation. ...


It is possible to have bidirectional iterators act like random access iterators, as moving forward ten steps could be done by simply moving forward a step at a time a total of ten times. However, having distinct random access iterators offers efficiency advantages. For example, a vector would have a random access iterator, but a list only a bidirectional iterator.


Iterators are the major feature which allow the generality of the STL. For example, an algorithm to reverse a sequence can be implemented using bidirectional iterators, and then the same implementation can be used on lists, vectors and deques. User-created containers only have to provide an iterator which implements one of the 5 standard iterator interfaces, and all the algorithms provided in the STL can be used on the container. A container is a type of data structure. ... A container is a type of data structure. ...


This generality also comes at a price at times. For example, performing a search on an associative container such as a map or set can be much slower using iterators than by calling member functions offered by the container itself. This is because an associative container's methods can take advantage of knowledge of the internal structure, which is opaque to algorithms using iterators. An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. ... A container is a type of data structure. ... A container is a type of data structure. ... An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. ... A container is a type of data structure. ...


Algorithms

A large number of algorithms to perform operations such as searching and sorting are provided in the STL, each implemented to require a certain level of iterator (and therefore will work on any container which provides an interface by iterators). A container is a type of data structure. ...


Functors

The STL includes classes that overload the function operator (operator()). Classes that do this are called functors or function objects. They are useful for keeping and retrieving state information in functions passed into other functions. Regular function pointers can also be used as functors. In computer science, polymorphism is the idea of allowing the same code to be used with different types, resulting in more general and abstract implementations. ... A function object, often called a functor, is a computer programming construct allowing an object to be invoked or called as if it were an ordinary function, usually with the same syntax. ...


A particularly common type of functor is the predicate. For example, algorithms like find_if take a unary predicate that operates on the elements of a sequence. Algorithms like sort, partial_sort, nth_element and all sorted containers use a binary predicate which must provide a strict weak ordering, that is, it must behave like a membership test on a transitive, irreflexive and antisymmetric binary relation. If none is supplied, these algorithms and containers use less by default, which in turn calls the less-than-operator <. In mathematics, a predicate is either a relation or the boolean-valued function that amounts to the characteristic function or the indicator function of such a relation. ... Unary function - Wikipedia /**/ @import /skins-1. ... A container is a type of data structure. ... In mathematics, a binary function, or function of two variables, is like a function, except that it has two inputs instead of one. ... A strict weak ordering is a binary relation that defines an equivalence relation and has the properties stated below. ... In mathematics, a set can be thought of as any collection of distinct objects considered as a whole. ... In mathematics, a binary relation (or a dyadic relation) is an arbitrary association of elements of one set with elements of another (perhaps the same) set. ... A container is a type of data structure. ...


Criticisms

Quality of compiler

The Quality of Implementation (QoI) of the C++ compiler has a large impact on usability of STL (and templated code in general):

  • Error messages involving templates tend to be very long and difficult to decipher. This problem has been considered so severe that a number of tools have been written which simplify and indent STL-related error messages to make them more comprehensible. A proposal to the new C++ Standard (concept checking) tries to reduce this problem.
  • Careless use of STL templates can lead to code bloat. This has been countered with special techniques within STL implementation (using void* containers internally) and by improving optimization techniques used by compilers.
  • Template instantiation tends to increase compilation time and memory usage (even by an order of magnitude). Until the compiler technology improves enough this problem can be only partially eliminated by very careful coding and avoiding certain idioms.

An indentation can mean two things: To make notches in something or form deep recesses in a coastline for instance. ... It has been suggested that this article or section be merged into Software bloat. ...

STL design issues

1. Design flaws due to limitations in the C++ language
  • Initialization of STL containers with constants within the source code is not as easy as data structures inherited from C.
2. Perceived flaws due to the requirement to maximize speed and minimize space usage
  • STL containers are not intended to be used as base classes (their destructors are deliberately non-virtual). Deriving from a container is a common mistake made by novices.[citation needed]
3. Other flaws, caused either by trade-offs in design or which have become more visible over time
  • The concept of iterators as implemented by STL can be difficult to understand at first: for example, if a value pointed to by the iterator is deleted, the iterator itself is then no longer valid. This is a common source of errors. Most implementations of the STL provide a debug mode which is slower but can locate such errors if used. However, at present no better replacement for iterators has been suggested and a similar problem exists in other languages, for example Java.
  • Compiler compliance does not guarantee that allocator objects, used for memory management for containers, will work with state dependent behavior. For example, a portable library can't define an allocator type that will pull memory from different pools using different allocator objects of that type. (Meyers, p. 50)
  • The set of algorithms is not complete — for example, the copy_if algorithm was left out by oversight (Stroustrup, p. 530).
  • The interface of some containers (in particular string) is bloated (Sutter and Alexandrescu, p. 79); others are considered insufficient.
  • Hashing containers were left out of the original standard, but have been added in Technical Report 1, a recent extension to C++.

A container is a type of data structure. ... A container is a type of data structure. ... A container is a type of data structure. ... In generic programming, a concept is a description of supported operations on a type, including syntax and semantics. ... Java language redirects here. ... A container is a type of data structure. ... A container is a type of data structure. ... In computer science, a hash table is a data structure that speeds up searching for information by a particular aspect of that information, called a key. ... A container is a type of data structure. ... Technical Report 1 (TR1) is a draft document specifying additions to the C++ Standard Library such as regular expressions, smart pointers, hash tables, and random number generators. ...

History

The architecture of STL is largely the creation of one person, Alexander Stepanov. In 1979 he began working out his initial ideas of generic programming and exploring their potential for revolutionizing software development. Although David Musser had developed and advocated some aspects of generic programming as early as 1971, it was limited to a rather specialized area of software development (computer algebra). Alexander Stepanov (born November 16, 1950 in Moscow) is the key person behind the C++ Standard Template Library, which he started to develop around 1993 while employed at HP Labs. ... Also: 1979 by Smashing Pumpkins. ... Generic programming is a style of computer programming where algorithms are written in an extended grammar and are made adaptable by specifying variable parts that are then somehow instantiated later by the compiler with respect to the base grammar. ... David R. Musser is a professor of computer science at Rensselaer Polytechnic Institute known for his work in generic programming, particularly as applied to C++. David Mussers home page Category: ... Year 1971 (MCMLXXI) was a common year starting on Friday (link will display full calendar) of the 1971 Gregorian calendar, known as the year of cyclohexanol. ... Symbolic mathematics, or symbolic math, relates to the use of computers to manipulate mathematical equations and expressions in symbolic form, as opposed to manipulating the approximations of specific numerical quantities represented by those symbols. ...


Stepanov recognized the full potential for generic programming and persuaded his then-colleagues at General Electric Research and Development (including, primarily, David Musser and Deepak Kapur) that generic programming should be pursued as a comprehensive basis for software development. At the time there was no real support in any programming language for generic programming. GE redirects here. ... David R. Musser is a professor of computer science at Rensselaer Polytechnic Institute known for his work in generic programming, particularly as applied to C++. David Mussers home page Category: ...


The first major language to provide such support was Ada, with its generic units feature. By 1987 Stepanov and Musser had developed and published an Ada library for list processing that embodied the results of much of their research on generic programming. However, Ada had not achieved much acceptance outside the defense industry and C++ seemed more likely to become widely used and provide good support for generic programming even though the language was relatively immature. Another reason for turning to C++, which Stepanov recognized early on, was the C/C++ model of computation which allows very flexible access to storage via pointers is crucial to achieving generality without losing efficiency. Ada is a structured, statically typed imperative computer programming language designed by a team led by Jean Ichbiah of CII Honeywell Bull during 1977–1983. ... This article is about the year 1987. ... The defense industry refers primarily to: Defense contractors: business organizations or individuals that provide products or services to a defense department of a government. ...


Much research and experimentation were needed, not just to develop individual components, but to develop an overall architecture for a component library based on generic programming. First at AT&T Bell Laboratories and later at Hewlett-Packard Research Labs, Stepanov experimented with many architectural and algorithm formulations, first in C and later in C++. Musser collaborated in this research and in 1992 Meng Lee joined Stepanov's project at HP and became a major contributor. Bell Telephone Laboratories or Bell Labs was originally the research and development arm of the United States Bell System, and was the premier corporate facility of its type, developing a range of revolutionary technologies from telephone switches to specialized coverings for telephone cables, to the transistor. ... The Hewlett-Packard Company (NYSE: HPQ), commonly known as HP, is a very large, global company headquartered in Palo Alto, California, United States. ... C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ... Year 1992 (MCMXCII) was a leap year starting on Wednesday (link will display full 1992 Gregorian calendar). ... Meng Lee is currently a Technical Contributor at Hewlett-Packard Research Labs. ...


This work undoubtedly would have continued for some time being just a research project or at best would have resulted in an HP proprietary library if Andrew Koenig of Bell Labs had not become aware of the work and asked Stepanov to present the main ideas at a November 1993 meeting of the ANSI/ISO committee for C++ standardization. The committee's response was overwhelmingly favorable and led to a request from Koenig for a formal proposal in time for the March 1994 meeting. Despite the tremendous time pressure, Alex and Meng were able to produce a draft proposal that received preliminary approval at that meeting. Andrew Koenig is a former AT&T researcher and programmer known for his work with C++. He is the author of C Traps and Pitfalls and his name is associated with Argument dependent name lookup, also known as “Koenig lookup”. Andrew Koenig on AcceleratedCpp. ... Bell Laboratories (also known as Bell Labs and formerly known as AT&T Bell Laboratories and Bell Telephone Laboratories) was the main research and development arm of the United States Bell System. ... Year 1993 (MCMXCIII) was a common year starting on Friday (link will display full 1993 Gregorian calendar). ... Year 1994 (MCMXCIV) The year 1994 was designated as the International Year of the Family and the International Year of the Sport and the Olympic Ideal by the United Nations. ...


The committee had several requests for changes and extensions (some of them major), and a small group of committee members met with Stepanov and Lee to help work out the details. The requirements for the most significant extension (associative containers) had to be shown to be consistent by fully implementing them, a task Stepanov delegated to Musser. It would have been quite easy for the whole enterprise to spin out of control at this point, but again Stepanov and Lee met the challenge and produced a proposal that received final approval at the July 1994 ANSI/ISO committee meeting. (Additional details of this history can be found in Stevens.) Subsequently, the Stepanov and Lee document 17 was incorporated into the ANSI/ISO C++ draft standard (1, parts of clauses 17 through 27). It also influenced other parts of the C++ Standard Library, such as the string facilities, and some of the previously adopted standards in those areas were revised accordingly. An associative array (also map, hash, dictionary, finite map, lookup table, and in query-processing an index or index file) is an abstract data type composed of a collection of keys and a collection of values, where each key is associated with one value. ... A container is a type of data structure. ...


In spite of STL's success with the committee, there remained the question of how STL would make its way into actual availability and use. With the STL requirements part of the publicly available draft standard, compiler vendors and independent software library vendors could of course develop their own implementations and market them as separate products or as selling points for their other wares. One of the first edition's authors, Atul Saini, was among the first to recognize the commercial potential and began exploring it as a line of business for his company, Modena Software Incorporated, even before STL had been fully accepted by the committee.


The prospects for early widespread dissemination of STL were considerably improved with Hewlett-Packard's decision to make its implementation freely available on the Internet in August 1994. This implementation, developed by Stepanov, Lee, and Musser during the standardization process, became the basis of many implementations offered by compiler and library vendors today.


Notes

References

Alexander Stepanov (born November 16, 1950 in Moscow) is the key person behind the C++ Standard Template Library, which he started to develop around 1993 while employed at HP Labs. ... Meng Lee is currently a Technical Contributor at Hewlett-Packard Research Labs. ... Scott Meyers is the author of several books on object oriented programming and especially the C++ computer programming language. ... Dr. Dobbs Journal (DDJ) is a monthly journal published in the United States by CMP Media. ... Bjarne Stroustrup Bjarne Stroustrup (IPA: ) (born December 30, 1950 in Aarhus, Denmark) is a computer scientist and the College of Engineering Chair Professor of Computer Science at Texas A&M University. ... Herb Sutter is one of the most prominent C++ experts. ... Andrei Alexandrescu is widely regarded as one of the foremost experts on advanced C++ programming. ...

See also

  • The Boost C++ Libraries, a large collection of portable C++ libraries, reviewed for quality and usually header-only. Some libraries from Boost will be included in the next revision of the C++ Standard.
  • C++0x

The Boost C++ Libraries are a collection of peer-reviewed, open source libraries that extend the functionality of C++. Most of the libraries are licensed under the Boost Software License, designed to allow Boost to be used with both open and closed source projects. ... C++0x is the planned new standard for the C++ programming language. ...

External links

Silicon Graphics, Inc. ...

  Results from FactBites:
 
Understanding the C++ Standard Template Library (2938 words)
Libraries come in different shapes, not to say sizes, and the shape of a library has a profound effect on its usability and ease of assimilation.
The STL is a relatively small library which achieves a remarkable degree of reuse through its basis in the principles of generic programming and its use of C++ templates.
Because STL algorithms are template functions specialised on the types of the iterators returned by the underlying containers it is perfectly reasonable to use the copy algorithm to move the contents of one container to another of a different type.
Standard Template Library - Wikipedia, the free encyclopedia (1926 words)
The STL has been a major boon for most of C++ programmers: it gives them a ready-made set of common classes, such as containers and associative arrays, that can be used with any built-in type and with any user-defined type that supports some elementary operations such as copying and assignment.
The Standard Template Library was created as the first library of generic algorithms and data structures, with four ideas in mind: generic programming, abstractness without loss of efficiency, the Von Neumann computation model, and value semantics.
Libraries implementing STL often include hashed variants: hash_set, hash_multiset, hash_map and hash_multimap, but these extensions are not part of the standard and are defined in various namespaces among implementations as a result.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.