|
1 | | -Collections framework has four main data structure types (list, set, queue and map). |
2 | | -List, set and queue interfaces extends Collection interface which extends Iterable interface. |
| 1 | +# Collections framework |
| 2 | +Collections framework has four main data structure types which are **list**, **set**, **queue** and **map**. |
| 3 | +``List``, ``Set`` and ``Queue`` interfaces in ``java.util`` extends ``java.util.Collection`` interface which extends ``java.lang.Iterable`` interface. |
3 | 4 |
|
4 | | -##### 1. List — Ordered collection of elements that can duplicate |
5 | | -- ArrayList: Standard re-sizable list. |
6 | | -- LinkedList: implements both List and Deque. Can easily add/remove from beginning or end. |
7 | | -- Vector: Older version of ArrayList, thread-safe. |
8 | | -- Stack: Older last-in, first-out class, newer version ArrayDeque is more flexible |
| 5 | +## Main data structure types |
| 6 | +### 1. **List** — Ordered collection of elements that can duplicate |
| 7 | +- ``ArrayList``: Standard re-sizable list. |
| 8 | +- ``LinkedList``: implements both ``List`` and ``Deque``. Can easily add/remove from beginning or end. |
| 9 | +- ``Vector``: Older version of ``ArrayList``, thread-safe. |
| 10 | +- ``Stack``: Older last-in, first-out class, newer version ``ArrayDeque`` is more flexible |
9 | 11 |
|
10 | | -##### 2. Set —Does not allow duplicates |
11 | | -- HashSet: Uses hashcode() to find unordered elements. |
12 | | -- TreeSet: implements NavigableSet which extends SortedSet. Does not allow null values. |
| 12 | +### 2. **Set** — Does not allow duplicates |
| 13 | +- ``HashSet``: Uses ``hashcode()`` to find unordered elements. |
| 14 | +- ``TreeSet``: implements ``NavigableSet`` which extends ``SortedSet``. Does not allow null values. |
13 | 15 |
|
14 | | -##### 3. Queue —Orders elements for processing |
15 | | -- LinkedList: Can easily add/remove from beginning or end. |
16 | | -- ArrayDeque: First-in, first-out or last-in, first-out. Does not allow null values. |
| 16 | +### 3. **Queue** — Orders elements for processing |
| 17 | +- ``LinkedList``: Can easily add/remove from beginning or end. |
| 18 | +- ``ArrayDeque``: First-in, first-out or last-in, first-out. Does not allow null values. |
17 | 19 |
|
18 | | -##### 4. Map —Maps unique keys to values |
19 | | -- HashMap: Uses hashcode() to find keys, allows null key |
20 | | -- TreeMap: Sorted map. Does not allow null keys. |
21 | | -- HashTable: Older version of HashMap. Does not allow null keys or values. |
| 20 | +### 4. **Map** — Maps unique keys to values |
| 21 | +- ``HashMap``: Uses ``hashcode()`` to find keys, allows null key |
| 22 | +- ``TreeMap``: Sorted map. Does not allow null keys. |
| 23 | +- ``HashTable``: Older version of ``HashMap``. Does not allow null keys or values. |
22 | 24 |
|
23 | | -Sorting: |
24 | | - - Collections.sort(List\<T extends Comparable> list) |
25 | | - - Collections.sort(List\<T> list, Comparator comparator) |
26 | | - - Use TreeMap to sort Map by key or value |
| 25 | +## Sorting |
| 26 | + - ``Collections.sort(List\<T extends Comparable> list)`` |
| 27 | + - ``Collections.sort(List\<T> list, Comparator comparator)`` |
| 28 | + - Use ``TreeMap`` to sort ``Map`` by key or value |
| 29 | + |
| 30 | + ## Helper classes |
| 31 | + ### ``java.util.Arrays`` |
| 32 | + It is a helper class for common unitility tasks on manipulating arrays such as _sorting_ and _searching_ in arrays |
| 33 | + |
| 34 | + |
0 commit comments