You are on page 1of 11

Collection Operations

Richard Warburton
@richardwarburto | www.insightfullogic.com
Algorithms Factories Utilities
Algorithms Factories Utilities
Set<Integer> set = Collections.singleton(1);
List<String> list = Collections.singletonList(“one”);
Map<Integer, String> map =
Collections.singletonMap(1, “one”);

Singletons
Immutable single value of collection

Use when you want to pass a single value to a method that takes a collection
Set<Integer> set = Collections.emptySet();
List<String> list = Collections.emptyList();
Map<Integer, String> map = Collections.emptyMap();
// and friends ...

Empty Collections
Immutable empty collection
Use when you want to pass a no values to a method that takes a collection
Algorithms Factories Utilities
Summary
This is the end … the only end my friend.
Collection

List Set Queue Map

SortedSet Deque SortedMap


Collection

List Map
Set Queue
ArrayList HashMap
HashSet PriorityQueue
LinkedList

Deque
SortedSet SortedMap
LinkedList
TreeSet TreeMap
ArrayDeque

You might also like