 |
Generic Programming and the STL View Larger Image | Matthew H. Austern Addison-Wesley, Hardcover, Published October 1998, 548 pages, ISBN 0201309564 | List Price: $59.99 Our Price: $46.50 You Save: $13.49 (22% Off)
| | | Availability: Out-Of-Stock |
Be the First to Write a Review and tell the world about this title!Books on similar topics, in best-seller order: Books from the same publisher, in best-seller order:
Many programmers are unaware that C++ is more than an object-oriented language. C++ is also a language for generic programming, a methodology that can greatly enhance your ability to write efficient and reusable software components.
Written by noted C++ authority Matthew H. Austern, Generic Programming and the STL introduces you to the generic programming paradigm and to the most important instance of that paradigm--the C++ Standard Template Library (STL). This book reveals that the STL is more than a set of convenient container classes: It is also an extensible framework for generic and interoperable components.
Generic Programming and the STL explains the central ideas underlying generic programming--concepts, modeling, and refinement--and shows how these ideas lead to the fundamental concepts of the STL: iterators, containers, and function objects. In this way you will conceive the STL as a library of concepts rather than a library of specific functions and classes. You will learn its formal structure and be able to take full advantage of its potential power. This book enables you to:
- Extend the STL with your own library of portable and interoperable general-purpose components
- Create algorithms that are decoupled from the types and data structures they operate on, thus eliminating the need to rewrite basic algorithms and data structures
- Write more elegant, efficient, and effective code that can be used and reused across platforms
With the knowledge and understanding you will gain, you can achieve greater skill in creating the reusable and portable software that is now invaluable in our diverse and interconnected computing environment.
Contents
Preface xv
Part I Introduction to Generic Programming 1
Chapter 1 A Tour of the STL 3
- 1.1. A Simple Example 3
- 1.2. Summary 7
Chapter 2 Algorithms and Ranges 9
- 2.1. Linear Search 9
- 2.1.1. Linear Search in C 10
- 2.1.2. Ranges 12
- 2.1.3. Linear Search in C++ 13
- 2.2. Concepts and Modeling 16
- 2.3. Iterators 19
- 2.3.1. Input Iterators 20
- 2.3.2. Output Iterators 22
- 2.3.3. Forward Iterators 24
- 2.3.4. Bidirectional Iterators 27
- 2.3.5. Random Access Iterators 28
- 2.4. Refinement 29
- 2.5. Summary 31
Chapter 3 More about Iterators 33
- 3.1. Iterator Traits and Associated Types 33
- 3.1.1. Value Types 33
- 3.1.2. Difference Type 36
- 3.1.3. Reference and Pointer Types 37
- 3.1.4. Dispatching Algorithms and Iterator Tags 38
- 3.1.5. Putting It All Together 41
- 3.1.6. Iterator Traits without
iterator_traits 43
- 3.2. Defining New Components 44
- 3.2.1. Iterator Adaptors 46
- 3.2.2. Advice for Defining an Iterator 47
- 3.2.3. Advice for Defining an Algorithm 47
- 3.3. Summary 48
Chapter 4 Function Objects 49
- 4.1. Generalizing Linear Search 49
- 4.2. Function Object Concepts 52
- 4.2.1. Unary and Binary Function Objects 52
- 4.2.2. Predicates and Binary Predicates 53
- 4.2.3. Associated Types 54
- 4.3. Function Object Adaptors 56
- 4.4. Predefined Function Objects 58
- 4.5. Summary 58
Chapter 5 Containers 59
- 5.1. A Simple Container 59
- 5.1.1. An Array Class 60
- 5.1.2. How It Works 63
- 5.1.3. Finishing Touches 63
- 5.2. Container Concepts 67
- 5.2.1. Containment of Elements 68
- 5.2.2. Iterators 68
- 5.2.3. The Hierarchy of Containers 70
- 5.2.4. The Trivial Container 71
- 5.3. Variable Size Container Concepts 72
- 5.3.1. Sequences 73
- 5.3.2. Associative Containers 75
- 5.3.3. Allocators 78
- 5.4. Summary 78
- 5.4.1. Which Container Should You Use? 78
- 5.4.2. Defining Your Own Container 79
Part II Reference Manual: STL Concepts 81
Chapter 6 Basic Concepts 83
- 6.1. Assignable 83
- 6.2. Default Constructible 84
- 6.3. Equality Comparable 85
- 6.4. Ordering 86
- 6.4.1. LessThan Comparable 86
- 6.4.2. Strict Weakly Comparable 88
Chapter 7 Iterators 91
- 7.1. Trivial Iterator 91
- 7.2. Input Iterator 94
- 7.3. Output Iterator 96
- 7.4. Forward Iterator 100
- 7.5. Bidirectional Iterator 102
- 7.6. Random Access Iterator 103
Chapter 8 Function Objects 109
- 8.1. Basic Function Objects 110
- 8.1.1. Generator 110
- 8.1.2. Unary Function 111
- 8.1.3. Binary Function 112
- 8.2. Adaptable Function Objects 113
- 8.2.1. Adaptable Generator 113
- 8.2.2. Adaptable Unary Function 114
- 8.2.3. Adaptable Binary Function 115
- 8.3. Predicates 116
- 8.3.1. Predicate 116
- 8.3.2. Binary Predicate 117
- 8.3.3. Adaptable Predicate 118
- 8.3.4. Adaptable Binary Predicate 119
- 8.3.5. Strict Weak Ordering 119
- 8.4. Specialized Concepts 122
- 8.4.1. Random Number Generator 122
- 8.4.2. Hash Function 123
Chapter 9 Containers 125
- 9.1. General Container Concepts 125
- 9.1.1. Container 125
- 9.1.2. Forward Container 131
- 9.1.3. Reversible Container 133
- 9.1.4. Random Access Container 135
- 9.2. Sequences 136
- 9.2.1. Sequence 136
- 9.2.2. Front Insertion Sequence 141
- 9.2.3. Back Insertion Sequence 143
- 9.3. Associative Containers 145
- 9.3.1. Associative Container 145
- 9.3.2. Unique Associative Container 149
- 9.3.3. Multiple Associative Container 152
- 9.3.4. Simple Associative Container 153
- 9.3.5. Pair Associative Container 155
- 9.3.6. Sorted Associative Container 156
- 9.3.7. Hashed Associative Container 161
- 9.4. Allocator 166
Part III Reference Manual: Algorithms and Classes 173
Chapter 10 Basic Components 175
- 10.1.
pair 175
- 10.2. Iterator Primitives 177
- 10.2.1.
iterator_traits 177
- 10.2.2. Iterator Tag Classes 179
- 10.2.3.
distance 181
- 10.2.4.
advance 183
- 10.2.5. Iterator Base Class 185
- 10.3.
allocator 187
- 10.4. Memory Management Primitives 189
- 10.4.1.
construct 189
- 10.4.2.
destroy 190
- 10.4.3.
uninitialized_copy 192
- 10.4.4.
uninitialized_fill 194
- 10.4.5.
uninitialized_fill_n 195
- 10.5. Temporary Buffers 196
- 10.5.1.
get_temporary_buffer 197
- 10.5.2.
return_temporary_buffer 198
Chapter 11 Nonmutating Algorithms 199
- 11.1. Linear Search 199
- 11.1.1.
find 199
- 11.1.2.
find_if 200
- 11.1.3.
adjacent_find 202
- 11.1.4.
find_first_of 204
- 11.2. Subsequence Matching 206
- 11.2.1.
search 206
- 11.2.2.
find_end 209
- 11.2.3.
search_n 211
- 11.3. Counting Elements 214
- 11.3.1.
count 214
- 11.3.2.
count_if 216
- 11.4.
for_each 218
- 11.5. Comparing Two Ranges 220
- 11.5.1.
equal 220
- 11.5.2.
mismatch 222
- 11.5.3.
lexicographical_compare 225
- 11.6. Minimum and Maximum 227
- 11.6.1.
min 227
- 11.6.2.
max 228
- 11.6.3.
min_element 229
- 11.6.4.
max_element 231
Chapter 12 Basic Mutating Algorithms 233
- 12.1. Copying Ranges 233
- 12.1.1.
copy 233
- 12.1.2.
copy_backward 236
- 12.2. Swapping Elements 237
- 12.2.1.
swap 237
- 12.2.2.
iter_swap 238
- 12.2.3.
swap_ranges 239
- 12.3.
transform 240
- 12.4. Replacing Elements 243
- 12.4.1.
replace 243
- 12.4.2.
replace_if 244
- 12.4.3.
replace_copy 246
- 12.4.4.
replace_copy_if 248
- 12.5. Filling Ranges 249
- 12.5.1.
fill 249
- 12.5.2.
fill_n 250
- 12.5.3.
generate 251
- 12.5.4.
generate_n 252
- 12.6. Removing Elements 253
- 12.6.1.
remove 253
- 12.6.2.
remove_if 255
- 12.6.3.
remove_copy 256
- 12.6.4.
remove_copy_if 258
- 12.6.5.
unique 259
- 12.6.6.
unique_copy 262
- 12.7. Permuting Algorithms 264
- 12.7.1.
reverse 264
- 12.7.2.
reverse_copy 265
- 12.7.3.
rotate 266
- 12.7.4.
rotate_copy 268
- 12.7.5.
next_permutation 269
- 12.7.6.
prev_permutation 271
- 12.8. Partitions 273
- 12.8.1.
partition 273
- 12.8.2.
stable_partition 274
- 12.9. Random Shuffling and Sampling 275
- 12.9.1.
random_shuffle 276
- 12.9.2.
random_sample 277
- 12.9.3.
random_sample_n 279
- 12.10. Generalized Numeric Algorithms 281
- 12.10.1.
accumulate 281
- 12.10.2.
inner_product 283
- 12.10.3.
partial_sum 285
- 12.10.4.
adjacent_difference 287
Chapter 13 Sorting and Searching 291
- 13.1. Sorting Ranges 291
- 13.1.1.
sort 292
- 13.1.2.
stable_sort 294
- 13.1.3.
partial_sort 297
- 13.1.4.
partial_sort_copy 300
- 13.1.5.
nth_element 301
- 13.1.6.
is_sorted 303
- 13.2. Operations on Sorted Ranges 305
- 13.2.1. Binary Search 305
- 13.2.2. Merging Two Sorted Ranges 316
- 13.2.3. Set Operations on Sorted Ranges 320
- 13.3. Heap Operations 336
- 13.3.1.
make_heap 336
- 13.3.2.
push_heap 338
- 13.3.3.
pop_heap 339
- 13.3.4.
sort_heap 342
- 13.3.5.
is_heap 343
Chapter 14 Iterator Classes 345
- 14.1. Insert Iterators 345
- 14.1.1.
front_insert_iterator 345
- 14.1.2.
back_insert_iterator 348
- 14.1.3.
insert_iterator 351
- 14.2. Stream Iterators 354
- 14.2.1.
istream_iterator 354
- 14.2.2.
ostream_iterator 357
- 14.2.3.
istreambuf_iterator 359
- 14.2.4.
ostreambuf_iterator 362
- 14.3.
reverse_iterator 363
- 14.4.
raw_storage_iterator 368
Chapter 15 Function Object Classes 371
- 15.1. Function Object Base Classes 371
- 15.1.1.
unary_function 371
- 15.1.2.
binary_function 372
- 15.2. Arithmetic Operations 373
- 15.2.1.
plus 373
- 15.2.2.
minus 375
- 15.2.3.
multiplies 376
- 15.2.4.
divides 378
- 15.2.5.
modulus 379
- 15.2.6.
negate 380
- 15.3. Comparisons 382
- 15.3.1.
equal_to 382
- 15.3.2.
not_equal_to 383
- 15.3.3.
less 384
- 15.3.4.
greater 386
- 15.3.5.
less_equal 387
- 15.3.6.
greater_equal 388
- 15.4. Logical Operations 390
- 15.4.1.
logical_and 390
- 15.4.2.
logical_or 391
- 15.4.3.
logical_not 393
- 15.5. Identity and Projection 394
- 15.5.1.
identity 394
- 15.5.2.
project1st 395
- 15.5.3.
project2nd 397
- 15.5.4.
select1st 398
- 15.5.5.
select2nd 399
- 15.6. Specialized Function Objects 400
- 15.6.1.
hash 400
- 15.6.2.
subtractive_rng 402
- 15.7. Member Function Adaptors 403
- 15.7.1.
mem_fun_t 404
- 15.7.2.
mem_fun_ref_t 406
- 15.7.3.
mem_fun1_t 408
- 15.7.4.
mem_fun1_ref_t 410
- 15.7.5.
const_mem_fun_t 412
- 15.7.6.
const_mem_fun_ref_t 414
- 15.7.7.
const_mem_fun1_t 416
- 15.7.8.
const_mem_fun1_ref_t 418
- 15.8. Other Adaptors 421
- 15.8.1.
binder1st 421
- 15.8.2.
binder2nd 422
- 15.8.3.
pointer_to_unary_function 424
- 15.8.4.
pointer_to_binary_function 426
- 15.8.5.
unary_negate 428
- 15.8.6.
binary_negate 429
- 15.8.7.
unary_compose 431
- 15.8.8.
binary_compose 433
Chapter 16 Container Classes 435
- 16.1. Sequences 435
- 16.1.1.
vector 435
- 16.1.2.
list 441
- 16.1.3.
slist 448
- 16.1.4.
deque 455
- 16.2. Associative Containers 460
- 16.2.1.
set 461
- 16.2.2.
map 466
- 16.2.3.
multiset 473
- 16.2.4.
multimap 478
- 16.2.5.
hash_set 484
- 16.2.6.
hash_map 488
- 16.2.7.
hash_multiset 494
- 16.2.8.
hash_multimap 499
- 16.3. Container Adaptors 504
- 16.3.1.
stack 505
- 16.3.2.
queue 507
- 16.3.3.
priority_queue 510
Appendix A Portability and Standardization 515
- A.1. Language Changes 516
- A.1.1. The Template Compilation Model 516
- A.1.2. Default Template Parameters 517
- A.1.3. Member Templates 518
- A.1.4. Partial Specialization 519
- A.1.5. New Keywords 521
- A.2. Library Changes 524
- A.2.1. Allocators 524
- A.2.2. Container Adaptors 525
- A.2.3. Minor Library Changes 526
- A.3. Naming and Packaging 527
Bibliography 531
Index 535
|
 |