Java Collections Framework

CSCI 1933 – Introduction to Algorithms and Data Structures
Adriana Picoral

Collections Framework

The collections framework is a unified architecture for representing and manipulating collections, enabling them to be manipulated independently of the details of their representation. It reduces programming effort while increasing performance.

The framework is based on more than a dozen collection interfaces. It includes implementations of these interfaces and algorithms to manipulate them.

List

  • ArrayList: Resizable-array implementation of the List interface.
  • LinkedList: Doubly-linked list implementation of the List and Deque interfaces.

Map

  • HashMap: Hash table based implementation of the Map interface. This implementation provides constant-time performance for the basic operations (get and put), assuming the hash function disperses the elements properly among the buckets.
  • TreeMap: A Red-Black tree. This implementation provides guaranteed log(n) time cost for the containsKey, get, put and remove operations.

Set

  • HashSet: This class implements the Set interface, backed by a hash table (actually a HashMap instance). This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets.
  • TreeSet: Implementation based on a TreeMap. This implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains).

Queue

  • PriorityQueue: An unbounded priority queue based on a priority heap.