T
- should implement the Comparable interfacepublic class InsertionSort<T extends java.lang.Comparable<T>> extends SortAlgorithm
Constructor and Description |
---|
InsertionSort(java.util.ArrayList<T> data)
constructor for creating an insertion sort instance via passing an ArrayList of data
|
InsertionSort(T[] dataArray)
constructor for creating an insertion sort instance via passing an array of data
|
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<T> |
getData() |
void |
setData(java.util.ArrayList<T> data) |
void |
sort()
this method sorts the data array using insertion sort algorithm
it doesn't return anything.To access the sorted data, call the getData method.
|
swap, swap
public InsertionSort(T[] dataArray)
dataArray
- an array of data of type Tpublic InsertionSort(java.util.ArrayList<T> data)
data
- an ArrayList of data of type Tpublic void setData(java.util.ArrayList<T> data)
data
- a new ArrayList that replaces the existing onepublic void sort()
public java.util.ArrayList<T> getData()