Web site design - Chapter 21 Collections 1229 public static method header
Tuesday, August 21st, 2007Chapter 21 Collections 1229 public static method header Collection unmodifiableCollection( Collection c ) List unmodifiableList( List aList ) Set unmodifiableSet( Set s ) SortedSet unmodifiableSortedSet( SortedSet s ) Map unmodifiableMap( Map m ) SortedMap unmodifiableSortedMap( SortedMap m ) Fig. 21.15Unmodifiable wrapper methods. 21.15 Software Engineering Observation 21.9 You can use an unmodifiable wrapper to create a collection that offers read-only access to others, while allowing read write access to yourself. You do this simply by giving others a reference to the unmodifiable wrapper while you also retain a reference to the wrapped collection itself. 21.11 Abstract Implementations The collections framework provides various abstract implementations (i.e., bare bones implementations of collection interfaces from which the programmer can quickly flesh out complete customized implementations). These abstract implementations are a thin Collection implementation called an AbstractCollection, a thin List implementation with random-access backing called an AbstractList, a thin Mapimplementation called an AbstractMap, a thin List implementation with sequential-access backing called an AbstractSequentialList and a thin Set implementation called an AbstractSet. To write a custom implementation, begin by selecting as a base the abstract-implementation class that best meets your needs. Next, implement each of the class s abstract methods. Then, if your collection is to be modifiable, override any concrete methods that prevent modification. 21.12 (Optional) Discovering Design Patterns: Design Patterns Used in Package java.util In this section, we use the material on data structures and collections discussed in Chapters 19, 20 and 21 to identify classes from package java.utilthat use design patterns. This section concludes our treatment of design patterns. 21.12.1 Creational Design Patterns We conclude the discussion of creational design patterns by discussing the Prototype design pattern. Prototype Sometimes, a system must make a copy of an object but will not know that object s class until run time. For example, consider the drawing program design of Exercise 9.28 class Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/12/01
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.