Collections Utilities and Choosing the Right Collection
The helper methods that save writing loops, and a practical way to pick the right collection every time.
Collection framework topics.
9 notes tagged
The helper methods that save writing loops, and a practical way to pick the right collection every time.
Comparable gives a class one natural order. Comparator supplies any number of orders from outside, without touching the class.
An Iterator walks a collection one element at a time, and it is the only safe way to remove during a traversal.
A Queue processes elements in an order it decides. A Deque works at both ends, and it is the right way to build a stack in Java.
Buckets, hashing, collisions and resizing. Understanding the mechanism explains the performance and every rule about keys.
A Map stores key to value pairs with unique keys, and it is the collection you will reach for most often.
A Set stores unique elements. The three implementations differ in ordering and in what uniqueness is based on.
A List keeps insertion order and allows duplicates. ArrayList is the default; LinkedList wins only at the ends.
A small set of interfaces describes how groups of objects behave, and many implementations trade memory, ordering and speed differently.