Java Generics and Collections. 2nd Edition Miasteczko Śląskie

Java Generics and Collections has been the go-to guide to generics for more than a decade. This second edition covers Java 21, providing a clear guide to generics from their most common uses to the strangest corner cases, giving you everything you need to know to use and write generic APIs …

od 186,15 Najbliżej: 31 km

Liczba ofert: 1

Oferta sklepu

Opis

Java Generics and Collections has been the go-to guide to generics for more than a decade. This second edition covers Java 21, providing a clear guide to generics from their most common uses to the strangest corner cases, giving you everything you need to know to use and write generic APIs effectively. It covers the collections library thoroughly, so youll always know how and when to use each collection for any given task. And it explains stream processing, so youll know which model to use and how they interoperate to get the best out of the platform library. This indispensable guide covers: Fundamentals of generics: type parameters and generic methods Subtyping and wildcards Generics and reflection Design patterns for generics Sets, queues, lists, maps, and their implementations Concurrent programming and thread safety with collections Performance of different collection implementations Best practices for using and extending the Java collections framework Design philosophy and comparison with other collections libraries Spis treści: Preface Acknowledgments for the Second Edition Intended Audience Obtaining the Example Programs Conventions Used in This Book Assertions OReilly Online Learning How to Contact Us Preface to the First Edition Acknowledgments for the First Edition I. Generics 1. Introduction Generic Types Generics Versus Templates Generic Methods and Varargs Primitive and Reference Types Conclusion 2. Subtyping and Wildcards Subtyping and the Substitution Principle Wildcards Wildcards with extends Wildcards with super The Get and Put Principle Arrays Bounded or Unbounded? Using an Unbounded Wildcard Using a Bounded Wildcard Wildcard Capture Restrictions on Wildcards Instance Creation Generic Method Calls Supertypes Conclusion 3. Comparison and Bounds Comparable The Contract for Comparable Consistent with equals Comparing Integral Values The Maximum of a Collection A Fruity Example Comparator Comparator Methods Enumerated Types Multiple Bounds Bridge Methods Covariant Overriding Conclusion 4. Declarations Constructors Static Members Nested Classes How Erasure Works Conclusion 5. Reifiable and Nonreifiable Types Reifiable Types Instance Tests and Casts Unchecked Casts Exception Handling Generics and Arrays Generic Array Creation The Principle of Truth in Advertising How to Create Arrays Array Begets Array A Classy Alternative How to Define ArrayList The Principle of Indecent Exposure Array Creation and Varargs Where Reifiable Types Are Required On the Design of Java Generics Erasure Unbounded Wildcards Arrays Arrays::copyOf Conclusion 6. Reflection Generics for Reflection Reflected Types Are Reifiable Types Reflection for Primitive Types A Generic Reflection Library Reflection for Generics Reflecting Generic Types Conclusion 7. Effective Generics Eliminate Unchecked Warnings Enforce Type Safety When Calling Untrusted Code Specialize to Create Reifiable Types Avoid Single-Use Type Variables Use Generic Helper Methods to Capture a Wildcard Cast Through Raw Types When Necessary Use Generic Array Types with Care Use Type Tokens for Run-Time Type Information Conclusion II. Collections 8. The Main Interfaces of the Java Collections Framework Using the Different Collection Types Set List Map SequencedMap Queue Sequenced Collections SequencedCollection SequencedSet and NavigableSet Deque SequencedMap and NavigableMap Conclusion 9. Preliminaries Iterable and Iterators Implementations Views Performance Memory Instruction Count and the O-notation Immutability and Unmodifiability Contracts Content-Based Organization Lambdas and Streams Parallel Streams Collections and Thread Safety Synchronization and the Legacy Collections Synchronized Collections and Fail-Fast Iterators Concurrent Collections Mechanisms of concurrent collections Iterators Conclusion 10. The Collection Interface The Methods of Collection Adding Elements Removing Elements Querying the Contents of a Collection Making a Collections Contents Available for Further Processing Using the Methods of Collection Adding Elements Removing Elements Querying the Contents of a Collection Making a Collections Contents Available for Further Processing Implementing Collection Collection Constructors Conclusion 11. The SequencedCollection Interface The Methods of SequencedCollection Adding Elements Inspecting Elements Removing Elements Generating a Reversed View Conclusion 12. Sets Defining a Set: Equivalence Relations Set Implementations HashSet HashSet constructors CopyOnWriteArraySet EnumSet UnmodifiableSet Set Views of Maps SequencedSet LinkedHashSet NavigableSet The Methods of NavigableSet Retrieving the comparator Inspecting the first and last elements Removing the first and last elements Getting range views Getting closest matches Navigating the set in reverse order NavigableSet now extends SequencedSet TreeSet ConcurrentSkipListSet Comparing Set Implementations Conclusion 13. Queues Queue Interface Methods Adding an Element to a Queue Retrieving an Element from a Queue Using the Methods of Queue Queue Implementations PriorityQueue ConcurrentLinkedQueue BlockingQueue The Methods of BlockingQueue Adding an element Removing an element Retrieving or querying the contents of the queue Using the Methods of BlockingQueue BlockingQueue Implementations LinkedBlockingQueue ArrayBlockingQueue PriorityBlockingQueue DelayQueue SynchronousQueue TransferQueue Deque The Methods of Deque Collection-like methods Queue-like methods Methods inherited from SequencedCollection Deque Implementations ArrayDeque LinkedList BlockingDeque Implementing BlockingDeque Comparing Queue Implementations Conclusion 14. Lists List Interface Methods Positional Access Methods Search Methods View-Generating Methods List Iteration Methods Methods Inherited from SequencedCollection Factory Methods Using the Methods of List Using Range-View and Iterator Methods List Implementations ArrayList LinkedList CopyOnWriteArrayList UnmodifiableList Comparing List Implementations Conclusion 15. Maps Map Interface Methods Iterable-like Operations Collection-like Operations Adding or replacing associations Removing associations Querying the contents of a map Providing Collection Views of the Keys, Values, or Entries Compound Operations Pessimistic-style atomic operations Optimistic-style atomic operations Factory Methods The Interface Map.Entry Using the Methods of Map Map Implementations HashMap WeakHashMap IdentityHashMap EnumMap UnmodifiableMap SequencedMap The Methods of SequencedMap Adding or updating entries Inspecting entries Removing entries View-generating methods LinkedHashMap NavigableMap Retrieving the Comparator Getting Range Views Getting Closest Matches Other Views TreeMap ConcurrentMap ConcurrentHashMap ConcurrentNavigableMap ConcurrentSkipListMap Comparing Map Implementations Conclusion 16. The Collections Class Generic Algorithms Changing the Order of List Elements Changing the Contents of a List Finding Extreme Values in a Collection Finding Specific Values in a List Collection Factories Wrappers Synchronized Collections Unmodifiable Collections Checked Collections Other Methods Conclusion 17. Guidance for Using the Java Collections Framework Avoid Anemic Domain Models Respect the Ownership of Collections Prefer Immutable Objects as Set Elements or Map Keys Balance Client and Library Interests in API Design Exploit the Features of Records Prefer Records to Parallel Lists Use Records as Composite Keys Manage the Mutability of Records Avoid Legacy Implementations Avoid Synchronized Wrapper Collections Using synchronized collections safely Avoid LinkedList Customize Collections Using the Abstract Classes Conclusion 18. Design Retrospective Fundamental Issues in the Collections Framework Design Desirable Characteristics of a Collections Framework Unmodifiability via Subtyping Limitations of Subtyping Complementing Static Typing Lumping and Splitting Summary nulls Inconsistent with equals Object Versus E Concurrent Modification Afterword Bibliography Index

Specyfikacja

Podstawowe informacje

Autor
  • Maurice Naftalin, Philip Wadler
Rok wydania
  • 2025
Format
  • MOBI
  • EPUB
Ilość stron
  • 368
Kategorie
  • Programowanie