Stepanov-The Standard Template Library-1994
Stepanov-The Standard Template Library-1994
a:aI.PACKARD
Alexander Stepanov
MengLee
Hewlett Packard Laboratories
1501 Page Mill Road, Palo Alio, CA 94304
stepanovtehpl.hp.com & [email protected]
March 7, 1994
___J
The design principles:
1. Comprehensive
- take all the bestfrom APL, Lisp, Dylan, C library, USL Standard Components...
- provide structure andfill the gaps
2. Extensible
- orthogonality ofthe component space
- semantically based interoperability guarantees
3. Emcient
- no penalty for generality
- complexity guarantees at the interface level
4. Natural
- C/C++ machine model and programming paradigm
- support for built-in data types
/
The Standard Template Library 2 Fli;'HEWLETT
a:~ PACKARD
Component Classification:
int a[lOOO]i
int b(2000)i
int c[3000);
Vector<int> Xi
List<int> Yi
int z [ ... )
4 rG'l HEWLETT
~~PACKARD
MergeCopy(l)
5 rG'll HEWLETT
~z.tI PACKARD
,
j
i
I
I
f
t
I
MergeCopy(2)
FJiiiW HEWLETT
~~PACKARD
Intmerge
'include <8tl.h>
r~HEWLETT
The Standard T...... LInry 8
Ito. PACKARD
Partial sort
linclude <stl.h>
'include <stl.h>
'include -string.H N
Vector:
random access
constant time (amortized) insert and erase at the end
List:
sequentialaccess
constant time insert and erase anywhere
Deque:
random access (but slower than Vector)
constant time insert and erase at the beginning .and the end
Additional
• Iterator, result iterator - weaker versions of forward iterators
• Insert iterator - special kind of result iterator
• Bidirectional reverse iterator, random access reverse iterator - reverse iterators
-0,
prints: true
prints: true
Example:
int a[10000]i
1. lIP position:
- make the library widely available
,
• ::~ reference implementation and validation suite are under consideration