
A generic method
to use with Generators............ 453
A general-purpose Generator.454
Simplifying tuple use ................. 455
A Set utility................................ 456
Anonymous
inner classes ...................... 459
Building
complex models................. 461
The mystery of erasure...... 463
The C++ approach ..................... 464
Migration compatibility ............. 466
The problem with erasure.......... 467
The action at the boundaries ..... 469
Compensating
for erasure ......................... 472
Creating instances of types ........ 473
Arrays of generics....................... 475
Bounds...............................480
Wildcards ..........................483
How smart is the compiler?....... 485
Contravariance........................... 487
Unbounded wildcards................ 489
Capture conversion .................... 494
Issues ................................. 495
No primitives
as type parameters ..................... 495
Implementing
parameterized interfaces ........... 497
Casting and warnings................. 497
Overloading................................ 499
Base class hijacks an interface ... 499
Self-bounded types............500
Curiously-recurring generics .....500
Self-bounding............................. 502
Argument covariance ................. 504
Dynamic type safety ..........506
Exceptions ......................... 507
Mixins................................509
Mixins in C++ ............................ 509
Mixing with interfaces ................510
Using the Decorator pattern .......512
Mixins with dynamic proxies......513
Latent typing ......................515
Compensating for
the lack of latent typing..... 518
Reflection ....................................519
Applying a method
to a sequence.............................. 520
When you don’t happen
to have the right interface.......... 522
Simulating latent typing
with adapters ..............................524
Using function objects
as strategies .......................526
Summary: Is casting
really so bad?..................... 531
Further reading...........................533
Arrays 535
Why arrays are special ...... 535
Arrays are
first-class objects ...............536
Returning an array ............539
Multidimensional
arrays .................................540
Arrays and generics........... 543
Creating test data .............. 545
Arrays.fill()..............................546
Data Generators.......................547
Creating arrays
from Generators ...................... 551
Arrays utilities ................. 555
Copying an array.........................555
Comparing arrays .......................557
Array element comparisons ....... 557
Sorting an array .......................... 561
Searching a sorted array.............562
Summary ...........................563
Containers in Depth 567
Full container taxonomy ... 567
Filling containers...............568
A Generator solution ...............569
Map generators.......................... 571
Using Abstract classes..............573
Collection
functionality ......................580
Optional operations...........583
Unsupported operations............ 584
List functionality ..............586
Sets and storage order......589
SortedSet..................................592
Queues ...............................593
Priority queues............................594
Deques ........................................595
Understanding Maps........596
Performance .............................. 598
SortedMap .............................. 600
LinkedHashMap.....................601
Hashing and hash codes....602
Understanding hashCode().... 605
Hashing for speed...................... 608