Collection

A mind map to quickly demonstrate collections interface in Java

Começar. É Gratuito
ou inscrever-se com seu endereço de e-mail
Collection por Mind Map: Collection

1. List

1.1. ArrayList- for each time the element added exceeds the size, ArrayList increases size as n+n/2 +1

1.1.1. add( element )

1.1.2. add( index , element )

1.1.3. get( index )

1.1.4. remove( index )

1.1.4.1. remove( type eg. Integer.valueOf(30) jis type ka arraylist us type ke element ki value)

1.1.5. addAll( list )

1.1.6. clear()

1.1.7. set( index , value )

1.1.8. contains

1.2. LinkedList

1.3. Stack

1.3.1. push()

1.3.2. peek() --> to get the value of topmost element in the stack

1.3.3. pop() --> removes the topmost element from stack

1.4. Vector

2. Circle

2.1. Interface

3. Rectangle

3.1. Class

4. Set --> only unique elements and order of elements is not preserved (implemented by hashing in the memory)

4.1. add( element )

4.2. remove( element )

4.3. contains( element )

4.4. isEmpty()

4.5. size()

4.6. clear()

4.7. EnumSet

4.8. HashSet

4.9. LinkedHashSet --> preserves the order of elements as well along with including properties of a set

4.10. TreeSet --> behind the scene the elements are sorted by using binary search tree

5. Iterator- type should be the same as that of the collection it is iterating. eg. Iterator<Integer> it= list.iterator(); Other commands include- it.hasNext() and it.next();

5.1. **ListIterator**

6. Queue

6.1. ArrayQueue

6.1.1. offer() --> adds element to the queue if operation is successful it returns TRUE else FALSE

6.1.2. poll() --> removes the element added in the beginning from the queue; returns NULL if queue is empty

6.1.3. remove() --> throws an exception if queue is empty

6.1.4. add() --> throws an exception if the element is not added successfully else returns TRUE

6.1.5. element() --> returns the head of the queue and throws an exception if the queue is empty

6.1.6. peek() --> tells us the element next in line to be removed (head of the queue and returns NULL if queue is empty

6.2. PriorityQueue --> is a type of queue in which we give priority to certain elements (by default ascending order i.e. minHeap implementation)

6.2.1. use Comparator.reverseOrder() to reverse the order

6.3. LinkedList

6.4. **Dqueue**

6.4.1. offerFirst() --> add in beginning

6.4.2. offerLast() --> add at last

6.4.3. pollFirst() or poll ()--> removes head

6.4.4. pollLast() --> removes the last element of dqueue

7. Map --> stores elements in Key, Value pairs where key is unique, and the pair is overwritten when a duplicate value of Key is passed with a different Value

7.1. put( Key , Value )

7.2. putIfAbsent( Key , Value )

7.3. containsKey( Key )

7.4. containsValue( Value )

7.5. isEmpty()

7.6. clear()

7.7. keySet() --> to give the set of only keys

7.8. values() --> to give the set of only values

7.9. getOrdefault(key, default value) --> returns the value corresponding to the key if present or returns the default value

7.10. TreeMap --> sorted map on the basis on Key

7.11. EnumMap

7.12. LinkedHashMap

7.13. WeakHashMap

7.14. HashMap

8. To iterate over the map use this --> for (Map.Entry<String,Integer> e : numbers.entrySet()){ e.getKey(), e.getValue(), e}

9. **Arrays**

9.1. binarySearch( array , element) --> gives the index of element in array

9.2. sort( array ) --> uses quick sort to sort array

9.3. fill( array , value ) --> used to fill entire array with value

10. **Collections**

10.1. min(list)

10.2. max(list)

10.3. frequency( list , element )

10.4. sort( list , Comparator.reverseOrder())