Standard Template Library

aesthetics  →
being  →
complexity  →
database  →
enterprise  →
ethics  →
fiction  →
history  →
internet  →
knowledge  →
language  →
licensing  →
linux  →
logic  →
method  →
news  →
perception  →
philosophy  →
policy  →
purpose  →
religion  →
science  →
sociology  →
software  →
truth  →
unix  →
wiki  →
essay  →
feed  →
help  →
system  →
wiki  →
critical  →
discussion  →
forked  →
imported  →
original  →
Standard Template Library
[ temporary import ]
please note:
- the content below is remote from Wikipedia
- it has been imported raw for GetWiki
{{C++ Standard library}}{{Other uses|STL (disambiguation){{!}}STL}}The Standard Template Library (STL) is a software library for the C++ programming language that influenced many parts of the C++ Standard Library. It provides four components called algorithms, containers, functions, and iterators.BOOK, Holzner, Steven, C++ : Black Book, 2001, Coriolis Group, Scottsdale, Ariz., 1-57610-777-9, 648, The STL is made up of containers, iterators, function objects, and algorithms, The STL provides a 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.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 abstraction penalties arising from heavy use of the STL.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,BOOK, Musser, David, STL tutorial and reference guide: C++ programming with the standard template library, Addison Wesley, 2001, 0-201-37923-6, and value semantics.


In November 1993 Alexander Stepanov presented a library based on generic programming to the ANSI/ISO committee for C++ standardization. The committee's response was overwhelmingly favorable and led to a request from Andrew Koenig for a formal proposal in time for the March 1994 meeting. The committee had several requests for changes and extensions and the committee members met with Stepanov and Meng 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 David Musser. A proposal received final approval at the July 1994 ANSI/ISO committee meeting. Subsequently, the Stepanov and Lee document 17 was incorporated into the ANSI/ISO C++ draft standard (1, parts of clauses 17 through 27).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.



The STL contains sequence containers and associative containers. The containers are objects that store data. The standard sequence containers include {{Cpp|vector}}, {{Cpp|deque}}, and {{Cpp|list}}. The standard associative containers are {{Cpp|set}}, {{Cpp|multiset}}, {{Cpp|map}}, {{Cpp|multimap}}, {{Cpp|hash_set}}, {{Cpp|hash_map}}, {{Cpp|hash_multiset}} and {{Cpp|hash_multimap}}. There are also container adaptors {{Cpp|queue}}, {{Cpp|priority_queue}}, and {{Cpp|stack}}, that are containers with specific interface, using other containers as implementation.{| class="wikitable"! Container! Description
! colspan="2" | Simple containers
! pair| The pair container is a simple associative container consisting of a 2-tuple of data elements or objects, called 'first' and 'second', in that fixed order. The STL 'pair' can be assigned, copied and compared. The array of objects allocated in a map or hash_map (described below) are of type 'pair' by default, where all the 'first' elements act as the unique keys, each associated with their 'second' value objects.
! colspan=2| Sequences (arrays/linked lists): ordered collections
! vector
dynamic array, like C (programming language)>C array (i.e., capable of random access) with the ability to resize itself automatically when inserting or erasing an object. Inserting an element to the back of the vector at the end takes amortized constant time. Removing the last element takes only constant time, because no resizing happens. 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.
! 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).
! slist
Linked list>singly 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). It has slightly more efficient insertion and deletion, and uses less memory than a doubly linked list, but can only be iterated forwards. It is implemented in the C++ standard library as {{Cpp|forward_list}}.
! 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.
! colspan=2| Container adaptors
! queue
FIFO (computing and electronics)>FIFO Queue (data structure) interface in terms of {{Cpp>push}}/{{Cppfront}}/{{Cpp|back}} operations.Any sequence supporting operations {{Cpp|front()}}, {{Cpp|back()}}, {{Cpp|push_back()}}, and {{Cpp|pop_front()}} can be used to instantiate queue (e.g. {{Cpp|list}} and {{Cpp|deque}}).
! priority queue
priority queue interface in terms of {{Cpp>push/pop/top}} operations (the element with the highest priority is on top).Any random-access sequence supporting operations {{Cpp|front()}}, {{Cpp|push_back()}}, and {{Cpp|pop_back()}} can be used to instantiate priority_queue (e.g. {{Cpp|vector}} and {{Cpp|deque}}). It is implemented using a heap.Elements should additionally support comparison (to determine which element has a higher priority and should be popped first).
! stack
LIFO (computing)>LIFO stack (data structure) interface in terms of {{Cpp>push/pop/top}} operations (the last-inserted element is on top).Any sequence supporting operations {{Cpp|back()}}, {{Cpp|push_back()}}, and {{Cpp|pop_back()}} can be used to instantiate stack (e.g. {{Cpp|vector}}, {{Cpp|list}}, and {{Cpp|deque}}).
! colspan=2| Associative containers: unordered collections
! set
set (computer science)>set; inserting/erasing elements in a set does not invalidate iterators pointing in the set. Provides set operations union (set theory), intersection (set theory)>intersection, set difference
, symmetric difference and test of inclusion. Type of data must implement comparison operator {{Cpp>

- content above as imported from Wikipedia
- "Standard Template Library" does not exist on GetWiki (yet)
- time: 1:06pm EDT - Fri, May 24 2019
[ this remote article is provided by Wikipedia ]
LATEST EDITS [ see all ]
M.R.M. Parrott