Upload
bharat-savani
View
217
Download
0
Embed Size (px)
Citation preview
Java Collections Framework Interfaces
Quick walk through of interfaces of Collections Framework.
Interfaces of Collections Framework
• Collection<E> interface– Group of Objects. – Collection aka Container of Objects. – Collection is root interface of Java Collections
Framework. – No direct implementation. – All Collections are Iterable. – No mention of what the Collection is or how
Objects are stored.
• List<E> interface– List extends Collection. – Ordered (on index) collection. – ArrayList (positional or index access) and
LinkedList (sequential access) are popular implementations.
– Allows duplicates.
• Set<E> interface– Set extends Collection. – Un-ordered Collection. – HashSet (uses hash function) is popular
implementation. – Duplicates are not allowed. – HashSet TreeSet are popular implementations.
• SortedSet<E> interface– SortedSet extends Set. – Set whose elements are automatically sorted. – Provides ordering on elements based on
Comparable or Comparator interface.
• NavigableSet<E> interface– NavigableSet extends SortedSet. – Provides navigation methods reporting closest
matches for given search targets. – It can be traversed in ascending or descending
order.
• Queue<E> interface– Queue extends Collection. – Used to hold elements prior to processing. – Besides methods inherited from Collection
interface it provides additional insertion, extractions and inspection operations.
– PriorityQueue and LinkedList are popular implementations.
• Deque<E> interface– Deque extends Queue. – Deque is double ended queue with insertion and
removal of elements from both ends.
• BlockingQueue<E> interface– BlockingQueue extends Queue. – Waits for queue to become non-empty when
retrieving an element. – And waits for space to become available in queue
when storing an element. – ArrayBlockingQueue and LinkedBlockingQueue are
popular implementation.
• TransferQueue<E> interface– TransferQueue extends BlockingQueue. – It is type of BlockingQueue in which producers
may wait for consumers to receive elements. – LinkedTransferQueue is popular implementation.
• Map<K, V> interface– Mapping from keys to values.– Each key can map to at most one value.– Unordered.– Key-Value mappings are depends on Hash Function.– Map cannot contain duplicate keys but can contain
duplicate values.– HashMap<K, V> and LinkedHashMap<k, V> is
popular implementation
• SortedMap<K, V> interface– SortedMap extends Map. – Mapping in SortedMap are sorted by Key, either
by natural ordering or by Comparator provided.– TreeMap<K, V> is popular implementation.
• NavigableMap<K, V> interface– NavigableMap extends SortedMap. – Provides navigation methods reporting closest
matches for given search targets. – It can be traversed in ascending or descending
order.– TreeMap<K, V> is popular implementation.
• ConcurrentMap<K, V> interface– ConcurrentMap extends Map. – Provides thread safety and atomicity guarantees.
ConcurrentHashMap is popular implementation.– ConcurrentHashMap<K, V> is popular
implementation
• ConcurrentNavigableMap<K, V> interface– ConcurrentNavigableMap extends ConcurrentMap
and NavigableMap. – ConcurrentSkipListMap<K, V> is popular
implementation.
Thank you.