1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
\documentclass[11pt,twocolumn]{article}
\usepackage{graphicx}
\usepackage{color}
\usepackage{epstopdf}
\usepackage{alltt}
\usepackage{hyperref}

\hypersetup{colorlinks=true}

\textheight = 10.5 in
\linewidth = 8.0in
\oddsidemargin = 0.0 in
\evensidemargin = 0.0 in
\marginparwidth=0.0in
\marginparsep=0.0in
\topmargin = 0.0 in
\headheight = 0.0 in
\headsep = 0.0 in
\parskip = 1pt
\parindent = 0.0in

\setlength{\hoffset}{-24pt}
\setlength{\voffset}{-50pt}
\newcommand{\ttnrbf}[1]{\textnormal{\textbf{#1}}}
\newcommand{\ttnr}[1]{\textnormal{#1}}
\newcommand{\ttitbf}[1]{\textnormal{\textbf{#1}}}
\newcommand{\ttit}[1]{\textit{#1}}
\newcommand{\sSecBox}[1]{\begin{minipage}{3.5in}\begin{alltt}{\small\textrm{\textbf{#1}}}}
\newcommand{\eSecBox}{\end{alltt}\end{minipage}\\\rule{0pt}{0pt}\hrule}

\newcommand{\blt}{\makebox[2ex]{\(\bullet\)}}
\newcommand{\bsp}{\makebox[2ex]{}}

\newcommand{\ifa}{\(\Rightarrow\)}
\newcommand{\iffa}{\(\Leftrightarrow\)}
\newcommand{\dfa}{\makebox[2ex]{\(\mapsto\)}}    % Define Arrow

\newcommand{\E}{\makebox[0ex]{\(\cal{E}\)}{\scshape{y}}\ttnrbf{:}}
\newcommand{\T}{\makebox[0ex]{\(\cal{T}\)}{\scshape{x}}\ttnrbf{:}}
\newcommand{\F}{\makebox[0ex]{\(\cal{F}\)}{{n}}\ttnrbf{:}}
\newcommand{\C}{\makebox[0ex]{\(\cal{C}\)}{\scshape{t}}\ttnrbf{:}}
\newcommand{\M}{\makebox[1ex]{\makebox[0pt]{\scalebox{0.50}[1.0]{\(\cal{M}\)}}{\(_f\)}}\ttnrbf{:}}

\newcommand{\OO}{\makebox[1.4ex]{\(\mathcal{O}\)}}
\newcommand{\AO}{\makebox[1.6ex]{\(\mathcal{A}\)}\makebox[1.4ex]{\(\mathcal{O}\)}}


\definecolor{grey50}{gray}{0.50}
%\colorbox{grey50}{}
%\textcolor{blue}{}

\begin{document}

\pagestyle{empty}

\fbox{{\parbox[b]{3in}{\huge \bf C++ STL \\ \tiny \copyright 1997-2017 Mitch Richling \url{https://www.mitchr.me}  \\ Last Updated 2016-07-09}}}
\tiny

\sloppy

\sSecBox{Notation}
  \blt X        \dfa A container          \blt a, b   \dfa Objects of type X
  \blt T        \dfa X::value_type        \blt t      \dfa Object of type T  
  \blt K        \dfa X::key_type          \blt k      \dfa Object of type K  
  \blt C        \dfa X::key_compare       \blt c      \dfa Object of type C
  \blt p        \dfa Iterators to a.      \blt q      \dfa Iterators to b.
  \blt p1, p2   \dfa Iterator rng to a.   \blt q1, q2 \dfa Iterator rng to b.
  \blt i,i2,i3  \dfa Integral index       \blt ch     \dfa A char (charT)
  \blt NTS      \dfa Null term string     \blt st     \dfa Simple string
  \blt o1,o2,o3 \dfa Random objects       \blt N      \dfa Number of elements
  \blt pU       \dfa 1 arg predicate      \blt bU     \dfa binary predicate
  \blt fU       \dfa 1 arg function
  \blt CMP      \dfa Binary compare  (-1 for <, 0 for ==, 1 for >)
  \blt n,n1,n2  \dfa Object of type X::size_type
\eSecBox

\sSecBox{Basic Attributes}
  \blt Assignable: o1 = o2  is a valid expression
  \blt Default Constructible: A no-arg constructor exists
  \blt Equality Comparable : o1 == o2 is a valid boolean-like expression
       Derived:    \blt o1 != o2  \iffa !(o1 == o2)
       Invariants: \blt Identity:      &o1==&o2 \ifa o1==o2
                   \blt Reflexitivity: o1 == o2
                   \blt Symmetry       o1==o2 \iffa o2==o1
                   \blt Transitivity:  o1==o2 && o2==o3 \ifa o1==o3
  \blt LessThan Comparable: o1<o2 is a valid boolean-like expression
       Derived:    \blt o1>o2  \iffa o2<o1
                   \blt o1<=o2 \iffa !(o2<o1)
                   \blt o1>=o2 \iffa !(o1<o2)
                   \blt o1==o2 \iffa !(o1<o2) && !(o2<o1)
                   \blt o1!=o2 \iffa (o1<o2) || (o2<o1)
       Invariants: \blt Irreflexivity: o1<o2 must be false
                   \blt Antisymmetry:  o1<o2 \ifa !(o2<o1)
                   \blt Transitivity:  o1<o2 && o2<o3 \ifa o1<o3
\eSecBox

\sSecBox{Container}
  \T X::allocator_type    \T X::value_type        \T X::difference_type
  \T X::iterator          \T X::const_iterator    \T X::size_type
  \T X::pointer           \T X::const_pointer
  \T X::reference         \T X::const_reference
  \C X(b)      \dfa Copy all elements from b. \OO(b.size())
  \E a.begin() \dfa \OO(1)        \E a.end()      \dfa \OO(1)   
  \E a.size()  \dfa \OO(N)        \E a.max_size() \dfa \OO(N)
  \E a.empty() \dfa \OO(1)        \E a.swap(b)    \dfa \OO(N)
\eSecBox

\sSecBox{Forward Container}
  \blt If T is Equality Comparable, then X is too (elementwise, \OO(N)).
  \bsp Note: a==b \ifa (a.size()==b.size())
  \blt If T is LessThan Comparable, then X is too (elementwise, \OO(N)).
  \bsp Note:  a<b == lexicographical_compare(a,b).
  \blt Iterators for X are Forward Iterators.
\eSecBox

\sSecBox{Reversible Container}
  \T reverse_iterator           \T const_reverse_iterator
  \E a.rbegin()  \dfa same as X::reverse_iterator(a.end())
  \E a.rend()    \dfa same as X::reverse_iterator(a.begin())
  \blt Iterators for X are Bidirectional Iterators.
\eSecBox

\sSecBox{Random Access Container}
  \E a[n]    \dfa Access to element n, 0<=n<N [reference if a is mutable]
  \E a.at(n) \dfa Access to element at n.
  \blt Iterators for X are Random Access Iterators
\eSecBox 

\sSecBox{Sequence}
  \C X(n, t)             \dfa Construct X with n copies of t \OO(n) 
  \C X(q1, q2)           \dfa Copy range [q1, q2) into new object. \OO(q2-q1)
  \E a.front()           \dfa Same as *(a.first())  \AO(1)
  \E a.insert(p, t)      \dfa Insert a copy of t before p.
  \E a.insert(p, n, t)   \dfa Insert n copies of t before p.
  \E a.insert(p, q1, q2) \dfa Inserts stuff from [q1, q2) before p
  \E a.erase(p)          \dfa Erases element at p, returns ++p
  \E a.erase(p1, p2)     \dfa Erases [p1, p2).  returns ++p
  \E a.clear()           \dfa Same as a.erase(a.begin(), a.end())
  \E a.resize(n, t=T())  \dfa Resize adding copies of t if required
\eSecBox

\sSecBox{Front Insertion Sequence}
  \E a.push_front(t) \dfa same as a.insert(a.begin(), t)  \AO(1)
  \E a.pop_front()   \dfa same as a.erase(a.begin()).     \AO(1)
\eSecBox

\sSecBox{Back Insertion Sequence}
  \E a.back()       \dfa same as *(--a.end())            \AO(1)
  \E a.push_back(t) \dfa same as a.insert(a.begin(), t)  \AO(1)
  \E a.pop_back()   \dfa same as a.erase(--a.end())      \AO(1)
\eSecBox

\sSecBox{Associative Container}
  \C X(c)             \dfa Construct with c as compare
  \C X(q1, q2, c)     \dfa Copy from [q1, q2) and use c as compare
  \T key_type         \T value_compare         \T compare_type
  \E a.erase(k)       \dfa Destroy elements with key k (returns nothing)
  \E a.erase(p)       \dfa Destroy element at p (returns nothing) \AO(1)
  \E a.erase(p1, p2)  \dfa Destroy elements in [p, q) (returns nothing)
  \E a.clear()        \dfa Same as a.erase(a.begin(), a.end())
  \E a.find(k)
  \E a.count(k)       \dfa Return number of elements with key equal to k 
  \E a.equal_range(k)
\eSecBox

\sSecBox{Simple Associative Container}
  \blt X::key_type and X::value_type must be the same
  \blt X::iterator is the same as X::const_iterator (i.e. not mutable)
\eSecBox

\sSecBox{Pair Associative Container}
  \T X::mapped_type \dfa Same as T    \T X::value_type  \dfa pair<const Key, T>
\eSecBox

\sSecBox{Unique Associative Container}
  \blt No two elements can have equivalent key.  
  \blt Equality is based on the order for sorted UACs.
\eSecBox

\sSecBox{Sorted Associative Container}
  \T X::key_compare   \T X::value_compare
  \E a.lower_bound(k)  Return iterator to first key not less than k.     \OO(logN)
  \E a.upper_bound(k)  Return iterator to first key greater less than k. \OO(logN)
  \E a.equal_range(k)  Return pair(lower_bound(k), upper_bound(k)).      \OO(logN)
  \blt The keys must be LessThan Comparable.  
  \blt Iterators are bidirectional (ordered induced by key order)
  \blt find and count members are \OO(logN)
  \blt The keys are const -- (or at least no order changing modifications)
\eSecBox

\sSecBox{vector} #include <vector>
  \textcolor{blue}{vector<T, Allocator=>}
  \E a.capacity()  \dfa Return the current storage capacity.               \OO(1)
  \E a.reserve(n)  \dfa Make space for n elements (invalidating iterators) \OO(N)
  \blt Insert at the end is \AO(1), while insert beginning is \AO(N).  
  \blt Iterators can be invalidated by most any insert.
  \blt Element access is \OO(1).  
\eSecBox

\sSecBox{deque (pronounced DECK)} #include <deque>
  \textcolor{blue}{deque<T,  Allocator=>}
  \blt Insert at the beginning or end is \AO(1), others as bad as \AO(N).  
  \blt Iterators can be invalidated by most any insert.
  \blt Element access is \OO(1).  
\eSecBox

\sSecBox{list} #include <list>
  \textcolor{blue}{list<T,  Allocator=>}
  \E a.splice(p, &b)
  \E a.splice(p, &b, q)
  \E a.splice(p, &b, q1, q2)
  \E a.remove(t)             \dfa Remove all occurrences of t.   \OO(N)
  \E a.remote_if(pU)         \dfa Remove if f(*i) is true
  \E a.unique()              \dfa Keep first element of equal subsequences
  \E a.unique(pB)
  \E a.merge(b)
  \E a.merge(b, pB)
  \E a.reverse()             \dfa Reverse the list.  \OO(N)
  \E a.sort()                \dfa Sort the list.     \OO(NlogN)
  \E a.sort(pB)
  \blt Inserting an element ANYPLACE is \OO(1).  
  \blt Insertion and removal do not invalidate iterators.
\eSecBox

\sSecBox{map \& multimap} #include <map>
  \textcolor{blue}{map<Key, T, Compare=, Allocator=>}
  \E a[k] \dfa Access the reference to data part of elements.  Insert pair(k,T()) if missing.
  \blt Inserts do not invalidate iterators, pointers, or references.  
  \blt Element erasure invalidates iterators-like things pointing to the thing being eliminated.
  \textcolor{blue}{map<Key, T, Compare=, Allocator=>}
  \blt Just like a map, except that keys do not have to be unique.
\eSecBox

\sSecBox{set \& multiset} #include <set>
  \textcolor{blue}{set<Key, Compare=, Allocator=>}
  \blt A map with, logically, key==value for every element.
  \textcolor{blue}{multiset<Key, Compare=, Allocator=>}
  \blt Just like a set, except that keys do not have to be unique.
\eSecBox

\sSecBox{unordered\_map \& unordered\_multimap} #include <unordered\_map>
  \textcolor{blue}{unordered\_map<Key, T, Hash=, EqPred=, Allocator=>}
  \E a[k] \dfa Access the reference to data part of elements.  Insert pair(k,T()) if missing.
  \blt Inserts do not invalidate iterators, pointers, or references.  
  \blt Element erasure invalidates iterators-like things pointing to the thing being eliminated.
  \textcolor{blue}{unordered\_multimap<Key, T, Hash=, EqPred=, Allocator=>}
  \blt Just like a unordered\_map, except that keys do not have to be unique.
\eSecBox

\sSecBox{unordered\_set \& unordered\_multiset} #include <unordered\_set>
  \textcolor{blue}{unordered\_set<Key, Hash=, EqPred=, Allocator=>}
  \blt A unordered\_map with, logically, key==value for every element.
  \textcolor{blue}{unordered\_multiset<Key, Hash=, EqPred=, Allocator=>}
  \blt Just like a unordered\_set, except that keys do not have to be unique.
\eSecBox

\sSecBox{}
      \includegraphics[width=3in]{STLcontainers.pdf}
\eSecBox

\sSecBox{stack (LIFO)} #include <stack>
  \textcolor{blue}{stack<T, Container=dqueue<T>>}  -- Container adapter
  \E stack(X a=X())  \dfa Copy content of a into stack \OO(a.size())
  \T value_type    \bsp         \T size_type   \bsp          \T container_type
  \M empty() \dfa               \M top()  \dfa the back \OO(1)
  \M pop()   \dfa on back \OO(1)  \M push() \dfa off back \OO(1)
  \M size()  \dfa This one can be \OO(1), but can be as bad as \OO(N)
\eSecBox

\sSecBox{priority queue} #include <queue>
  \textcolor{blue}{priority_queue<T, Container=dqueue<T>, Compare=less<T>>}  -- Container adapter
  \C priority_queue(X a=X()) \dfa Copy content of a into stack
  \T value_type    \bsp            \T size_type   \bsp        \T container_type
  \M empty() \dfa \OO(1)             \M top()  \dfa \OO(1)
  \M pop()   \dfa from back \OO(?)   \M push() \dfa sorted \OO(?)
  \M size()  \dfa This one can be \OO(1), but can be as bad as \OO(N)
\eSecBox

\sSecBox{queue (FIFO)}
  \textcolor{blue}{queue<T, Container=dqueue<T>>}  -- Container adapter
  \C queue(X a=X())  \dfa Copy content of a into stack \OO(a.size())
  \T value_type       \bsp        \T size_type  \bsp             \T container_type
  \M back() \dfa \OO(1)             \M empty() \dfa \OO(1)           \M top() \dfa \OO(1)
  \M pop()  \dfa from back \OO(1)   \M push()  \dfa on front \OO(1)
  \M size() \dfa This one can be \OO(1), but can be as bad as \OO(N)
\eSecBox

\sSecBox{pair} #include <utility>
  \textcolor{blue}{pair<K, T>}  -- Contain a pair of objects
  \C pair(k, t)      \C pair()          \C pair(pair<K,T>)
  \T first_type      \T second_type
  \M first()         \M second()        \M make_pair(k, t)
  \blt If K and T are equality comparable then so is the pair
  \blt If K and T are LessThan comparable then so is the pair
\eSecBox

\sSecBox{Input Iterator}
  \ttnrbf{Expressions:}
   \E ++p        \dfa Preincrement
   \E (void)p++  \dfa Postincrement
   \E *p++       \dfa Postincrement and dereference
   \E *p         \dfa deference.  Can't read any element more than once.
   \E p->m       \dfa member access
\eSecBox

\sSecBox{Output Iterator}
   \E ++p        \dfa Preincrement
   \E (void)p++  \dfa Postincrement
   \E *p=t       \dfa Dereference assignment.  Only one time per element.
\eSecBox

\sSecBox{Forward Iterator}
  \blt Elements may be dereferenced multiple times and they can
  \bsp be be assigned to (via a dereference assignment) multiple times.
  \blt May be used any place an Output iterator or Input iterator can.
\eSecBox

\sSecBox{Bidirectional Iterator}
  \E p--  \dfa Postdecrement
  \E --p  \dfa Predecrement
\eSecBox

\sSecBox{Random Access Iterator}
  \E p += n  \dfa Increment n times
  \E p -= n  \dfa Decrement n times
  \E p+n     \dfa same as p+=n (n+p is OK too)
  \E p - n   \dfa same as p-=n
  \E p1 - p2 \dfa Returns integral distance
  \E p[n]    \dfa Get n-th value
  \E p[n]=t  \dfa Set the n-th value
  \blt A pointer IS a random access iterator and may be used in just
  \bsp about any place a RAI can be used.
\eSecBox 

\sSecBox{Iterator Adapters}
  \blt front_insert_iterator
  \blt back_insert_iterator
  \blt insert_iterator
  \blt reverse_iterator
  \blt reverse_bidirectional_iterator
\eSecBox

\sSecBox{Iterator Diagram}
    \includegraphics[width=3in]{STLiterators.pdf}
\eSecBox

\sSecBox{Algorithms: Non-modifying}
  \F count(p1, p2, t)     \dfa Number of times in [p1, p2) element ==t
  \F count_if(p1, p2, pU) \dfa Number of times in [p1, p2) pU is true
  \F for_each(p1, p2, fU) \dfa Evaluates fU on each thing in [p1, p2)
  \F find(p1, p2, t)
  \F find_if(p1, p2, pB)
  \blt (*) \dfa (o1, o2), (o1, o2, c)
  \bsp     \F min(*)               \F max(*)
  \blt (*) \dfa (p1, p2), (p1, p2, c)
  \bsp     \F min_element(*)       \F max_element(*)
  \blt (*) \dfa (p1, p2, t), (p1, p2, t, c)
  \bsp     \F equal_reverse(*)     \F lower_bound(*)    \F upper_bound(*)
  \blt (*) \dfa (p1, p2, q), (p1, p2, q, pB)
  \bsp     \F equal(*)             \F mismatch(*)
  \blt (*) \dfa (p1, p2, q1, q2), (p1, p2, q1, q2, pB)
  \bsp     \F find_end(*)          \F find_first_of(*)  \F search(*)
  \blt (*) \dfa (p1, p2), (p1, p2, pB)
  \bsp     \F adjacent_find(*)
  \blt (*) \dfa (p1, p2, n, t), (p1, p2, n, pB)
  \bsp     \F search_n(*)
  \blt (*) \dfa (p1, p2, t), (p1, p2, c)
  \bsp     \F binary_search(*)
  \blt (*) \dfa (p1, p2, q1, q2), (p1, p2, q1, q2, c)
  \bsp     \F lexicographical_compare(*)
\eSecBox

\sSecBox{Algorithms: Modifying}
  \blt (*) \dfa (p1, p2, q)
  \bsp     \F copy(*)              \F copy_backward(*)  \F uninitialized_copy(*)
  \bsp     \F swap_ranges(*)
  \bsp     \F reverse_copy(*)      \F unique_copy(*)    
  \blt (*) \dfa (p1, p2)
  \bsp     \F stable_sort(*)       \F unique(*)         \F sort(*)
  \bsp     \F iter_swap(*)         \F random_shuffle(*) \F reverse(*)
  \blt (*) \dfa (p1, p2, pB)
  \bsp     \F partition(*)         \F unique(*)         \F stable_partition(*)
  \blt (*) \dfa (p1, p2, c)
  \bsp     \F sort(*)              \F stable_sort(*)
  \blt (*) \dfa (p1, p2, t)
  \bsp     \F fill                 \F remove(*)         \F uninitialized_fill(*)
  \blt (*) \dfa (p1, p2, pU, t)
  \bsp     \F replace_copy_if(*)   \F replace_if(*)
  \blt (*) \dfa (first, middle, last), (first, middle, last, q)
  \bsp     \F rotate(*)            \F rotate_copy(*)
  \blt (*) \dfa (p1, p2, q, unryOp), (p1, p2, p3, q, binOp)
  \bsp     \F transform(*)         \F transform(*)
  \blt (*) \dfa (first, middle, last), (first, middle, last, c)
  \bsp     \F partial_sort(*)
  \F partial_sort_copy(first, last, result_first, result_last)
  \F partial_sort_copy(first, last, result_first, result_last, c)
  \F remove_copy(p1, p2, q, t)
  \F remove_copy_if(p1, p2, q, pU)
  \F generate(p1, p2, gen), 
  \F generate_n(p1, n, gen)
  \F fill_n(p1, n, t)
  \F random_shuffle(p1, p2, rand)
  \F remove_if(p1, p2, pU)
  \F replace(p1, p2, old_val, new_val)
  \F replace_copy(p1, p2, q, old_val, new_val)
  \F unique_copy(p1, p2, q, pB)
  \F uninitialized_copy(p1, n, t)
\eSecBox

\sSecBox{Algorithms: Set Stuff}
  \blt includes(p1, p2, q1, q2, c=less<>) \dfa true if [q1,q2) is a subset of [p1, p2)
  \blt (*) \dfa (p1, p2, q1, q2, w) (p1, p2, q1, q2, w, c) [output is placed at w]
  \bsp  \F set_difference              \F set_intersection
  \bsp  \F set_symmetric_difference    \F set_union
\eSecBox

\sSecBox{Algorithms: Random Stuff}
  \blt (*) \dfa (p1, p2, init_val), (p1, p2, init_val, binOp)
  \bsp  \F accumulate
  \blt (*) \dfa (p1, p2, p3, init_val), (p1, p2, p3, init_val, binOp1, binOp2)
  \bsp  \F inner_product
  \blt (*) \dfa (p1, p2, q), (p1, p2, q, binOp)
  \bsp  \F adjacent_difference         \F partial_sum
  \blt (*) \dfa (p1, p2), (p1, p2, c)
  \bsp  \F next_permutation            \F prev_permutation
  \F swapI(t1, t2)
\eSecBox

\sSecBox{Strings}
  \blt typedefs:  \blt typedef basic_string<char> string
  \bsp            \blt typedef basic_string<wchar_t> wstring
  \blt Strings are ALMOST containers!
  \bsp \blt The string name behaves like a random access iterator
  \bsp \blt Don't support pop_back, back, front
  \E a = o1                     \dfa Construct out of o1 (a charT or NTS)
  \E a += o1                    \dfa call append with o1 as argument
  \E a.c_str()                  \dfa Return pointer null terminated, c-style, string
  \E a.data()                   \dfa Return pointer array of charT (not null terminated)
  \M copy(charT* dst, n, pos=0) \dfa Copy n chrs of a starting at pos to dst.  
  \M length()                   \dfa returns size()
  \M reserve(n=0)
  \M resize(n, ch=charT())                       
  \blt (*) \dfa (pos=0, n=npos)
  \bsp  \M substr(*)   \M erase(*)
  \blt (*) \dfa (bs, pos=0), (nts, pos, n), (nts, pos=0), (ch, pos=0)
  \bsp  \M find(*)     \M find_first_not_of(*)   \M find_first_of(*)    
  \bsp  \M rfind(*)    \M find_last_not_of(*)    \M find_last_of(*)     
  \blt (*) \dfa (bs), (bs, pos, n), (nts), (nts, n), (n, ch), (q1, q2)
  \bsp  \M assign(*)   \M append(*)
  \blt (*) \dfa (pos1,n2,bs,pos2,n2), (pos1,n1,bs), (pos1,n1,nts), (pos1,n1,nts,n2), (pos1,n1,n2,ch)
  \bsp     \bsp (p1,p2,q1,q2),        (p1,p2,bs),   (p1,p2,nts),   (p1,p2,nts,n),    (p1,p2,n,ch)
  \bsp  \M replace(*)
  \blt (*) \dfa (pos, bs), (pos, bs, pos2, n), (pos, nts), (pos, nts, n), (pos, n, ch)
  \bsp  \M insert(*)
  \blt (*) \dfa (bs), (pos1,n,bs), (nts), (pos1,n1,bs,pos2,n2), (pos1,n1,nts,n2), (pos1,n1,nts)
  \bsp  \M compare(*)
\eSecBox

\end{document}





% \sSecBox{list} #include <forward_list>
%   \textcolor{blue}{list<T,  Allocator>}
%   \E a.splice(p, &b)
%   \E a.splice(p, &b, q)
%   \E a.splice(p, &b, q1, q2)
%   \E a.remove(t)             \dfa Remove all occurrences of t.   \OO(N)
%   \E a.remote_if(pU)         \dfa Remove if f(*i) is true
%   \E a.unique()              \dfa Keep first element of equal subsequences
%   \E a.unique(pB)
%   \E a.merge(b)
%   \E a.merge(b, pB)
%   \E a.reverse()             \dfa Reverse the list.  \OO(N)
%   \E a.sort()                \dfa Sort the list.     \OO(NlogN)
%   \E a.sort(pB)
%   \blt Inserting an element ANYPLACE is \OO(1).  
%   \blt Insertion and removal do not invalidate iterators.
% \eSecBox