HashSet and TreeSet are implemented on top of HashMap and TreeMap
respectively, in the obvious way: an object is a member of the set if and
only if it's a key in the association map. There are (at least) five ways
to construct the map:
1. Map each key to itself.
2. Map each key to the map.
3. Map each key to its class object
4 Map each key to the map's class object
5.Map each key to some other distinguished object.
Both choose #5, using a private static object used for that purpose. I'm
wondering if this was an arbitrary choice, or if there's some (perhaps
GC-related) reason for it, and, if so, what general principle it
illustrates.
|
|
0
|
|
|
|
Reply
|
mscottschilling (1976)
|
2/2/2007 9:06:10 PM |
|