RecapDifficulty: Advanced1 min

Recap: Sets and Queues

How sets decide sameness, the three set orders, heaps, and the replacement for Stack.

Sets and queues come down to the five ideas below, each listed with the card that covers it.

What the topic established, and which card it was on
The ideaWhere
A HashSet decides duplication with hashCode and equals on the elementSets: How a HashSet Decides What Counts as a Duplicate
add returns whether the element was new, saving a second lookupHashSet Example: Adding the Same Order Twice
HashSet has no order, LinkedHashSet keeps insertion order, TreeSet sortsHashSet vs LinkedHashSet vs TreeSet
A priority queue is a heap, so only the front element is in orderPriorityQueue Iteration Order: Printing Does Not Show Poll Order
Use ArrayDeque for queues and stacks; Stack is a Java 1.0 classStack vs ArrayDeque: Why the Stack Class Should Not Be Used

A set decides what is the same, and a queue decides what is next. Choosing one means choosing whose decision you want.