- Consistent API
- Reducing programmer efforts
- Increase Speed and quality
- Retrieve elements one by one
- Types of Iterators
- Interface used get elements of legacy collections (vector, hashtable)
- Remove operation cannot be performed
- Only forward direction is possible
- Can be used all collections types
- Support remove operation
- Cannot support adding new or replacing operation
- Only forward direction
- Only for List collection types
- Bi directional
- Any Iterator reference point to index just before index of first element
- Cannot create object of them, as they are interfaces
- Cannot Store duplicates
- Unordered collection
- Union => addAll
- Intersection => retainAll
- Difference => removeAll
- Value stored on basis of hash
- Null Allowed | Time Complexity is O(1)
- Uses hashmap to store values (constant value used to put in map)
- Can have duplicates
- Ordered in form of insertion
- Implemented by ArrayList, LinkedList, Stack and Vector
- Index base access and saving
- Searching by indexOf and lastIndexOf
- Can also get sub list by indices
- Dynamic Array
- Extends AbstractList and Implements List
- Allow random access
- Primitives cannot be used
HashMap vs HashTable
- HashMap is not thread safe, Hash Table is synchronised
- HashMap allow one null key and multiple null value but hashtable do not allow null key or value
- HashMap is implementation of hashing
- Priority Queue
- To access data in queue based on priority
- Does Not allow null
- Elements are ordered by natural order or by comparator provided
- Extends AbstractQueue, Abstract Collection
- Double Queue
- Allow addition and Removal from both ends
- Natural ordering or by comparator
- Have methods like head tail sub etc
- Navigational Map
- Provide navigation method, provide way to create sub map (head & tail)
- lowerKey(Object key) : Returns the greatest key strictly less than the given key, or if there is no such key.
- floorKey(Object key) : Returns the greatest key less than or equal to the given key, or if there is no such key.
- ceilingKey(Object key) : Returns the least key greater than or equal to the given key, or if there is no such key.
- higherKey(Object key) : Returns the least key strictly greater than the given key, or if there is no such key.
- descendingMap() : Returns a reverse order view of the mappings contained in this map.
- headMap(object toKey, boolean inclusive) : Returns a view of the portion of this map whose keys are less than (or equal to, if inclusive is true) toKey.
- subMap(object fromKey, boolean fromInclusive, object toKey, boolean toInclusive) : Returns a view of the portion of this map whose keys range from fromKey to toKey.
- tailMap(object fromKey, boolean inclusive) : Returns a view of the portion of this map whose keys are greater than (or equal to, if inclusive is true) fromKey.
- SortedSet and SortedMap
- Null key or null value are not allowed