Slide 4
Slide 4 text
Java Collections refresher
Java Collections has three major collection interfaces:
• List: items in insertion order
ArrayList.new [-3, 1, 4, 1, 5, 9] # [-3, 1, 4, 1, 5, 9]
• Set: unique items in no particular order
HashSet.new [-3, 1, 4, 1, 5, 9] # [1, -3, 4, 5, 9]
o SortedSet: unique items with given ordering
TreeSet.new [-3, 1, 4, 1, 5, 9] # [-3, 1, 4, 5, 9]
• Map: unique keys (in no particular order) with values
HashMap.new 'foo'=>0, 'bar'=>1, 'baz'=>2 # {baz=2, foo=0, bar=1}
o SortedMap: unique keys (with ordering) with values
TreeMap.new 'foo'=>0, 'bar'=>1, 'baz'=>2 # {bar=1, baz=2, foo=0}