Please enable JavaScript.
Coggle requires JavaScript to display documents.
Collection Framework - Coggle Diagram
Collection Framework
9 Key Interfaces of Collection Framework.
Collection (Interface)
Group of individual objects.
https://www.youtube.com/watch?v=pHOZBuUooYc&list=PLd3UqWTnYXOkVR3OR9UZGyEt9RFUbaTMZ&index=4
add(Object o)
addAll(Collection c)
remove(Object o)
removeAll(Collection c)
clear()
isEmpty()
size()
contains(Object o)
ContainsAll(Collection c)
toArray()
iterator()
List
List interface is used in ArrayList, LinkedList, Vector->Stack
ArrayList & Vector implements RandomAccess(I) so we can access any element randomly at same speed.
If frequent operation is retrival operation ArrayList is best option.
RandomAccess(I) present in java.util package, it doesn't contain any method because it is a marker Interface
ArrayList
ArrayList is best in retrival operation
ArrayList is worst in insertion in middle.
Difference b/w ArrayList & Vector
Non-Syncronized / Syncronized
No thread safety / thread safety
High performance / Low performance
Non-legacy / Legacy
https://youtu.be/lUmdH4Z9fs0?list=PLd3UqWTnYXOkVR3OR9UZGyEt9RFUbaTMZ&t=202
Collection -> List
add(int index, Object o) remove(int index) indexOf(Object o) lastIndexOf(Object o) get(int index) set(int index,Object o)
Set
No insertion order No duplicate
https://www.youtube.com/watch?v=m6NCeOQCKbk&list=PLd3UqWTnYXOkVR3OR9UZGyEt9RFUbaTMZ&index=7
Collection -> Set -> HashSet -> LinkedHashSet
Sorted Set & Navigable Set
insertion order are managed in SortedSet No duplicate
NavigableSet is used for navigation purposes.
Collection -> Set -> SortedSet
Collection -> Set -> SortedSet -> NavigableSet -> TreeSet
https://www.youtube.com/watch?v=qs4WHbw6K4E&list=PLd3UqWTnYXOkVR3OR9UZGyEt9RFUbaTMZ&index=9
Queue
FIFO
Collection -> Queue
Collection -> Queue -> PriorityQueue
Collection -> Queu -> BlockingQueue
Collection -> Queue -> BlockingQueue -> LinkedBlockingQueue
Collection -> Queue -> BlockingQueue -> PriorityBlockingQueue
https://www.youtube.com/watch?v=Nj5Vl2Vt_mA&list=PLd3UqWTnYXOkVR3OR9UZGyEt9RFUbaTMZ&index=10
Map
Used as Key Value pair.
Map -> HashMap
Map -> LinkedHashMap
Map -> WeakHashMap
Map -> IdentityHashMap
Map && dictionary -> Hashtable
Hashtable -> Properties
https://www.youtube.com/watch?v=go_Kub9_pxY&list=PLd3UqWTnYXOkVR3OR9UZGyEt9RFUbaTMZ&index=11
SortedMap & NavigableMap
Used to sort key value according to some sorting inputs
Map -> SortedMap
NavigableMap define utility navigations
Map -> SortedMap -> NavigableMap -> TreeMap
https://www.youtube.com/watch?v=Q_CUIsmN25Y&list=PLd3UqWTnYXOkVR3OR9UZGyEt9RFUbaTMZ&index=12
Before
Arrays
int[] arr = new int[5];
arr[0]
Vector
Vector<Integer> v = new Vector();
v.addElement(1);
v.elementAt(0)
Hashtable :
Hashtable<Integer, String> = new Hashtable();
h.put(1, "geeks");
h.get(1)
Sources
https://www.youtube.com/playlist?list=PLd3UqWTnYXOkVR3OR9UZGyEt9RFUbaTMZ
Collection Interface
Methods
add(Object o)
addAll(Collection c)
remove(Object o)
removeAll(Collection c)
clear()
retainAll(Collection c)
isEmpty()
size()
contains(Object o)
containsAll(Collection c)
toArray()
iterator()