edu.tum.cs.commons.collections
Class SortableDataUtils
java.lang.Object
edu.tum.cs.commons.collections.SortableDataUtils
public class SortableDataUtils
- extends java.lang.Object
Abstraction for sortable/comparable data. This class supports basic
algorithms, such as sorting and binary search on any data which can be mapped
to a random access list. The main benefit of this class, is that the type of
data is operated on must not be known (or be a concrete type), thus it can
also be used to sort data spread over multiple lists or arrays.
- Version:
- $Rev: 29399 $
- Author:
- hummelb, $Author: juergens $
- Rating:
- GREEN Hash: D91A00D48171C7C62E158FE291D7FCA9
Method Summary |
static int |
binarySearch(ISortableData data,
int elementIndex)
Performs a binary search for the element at the given index. |
static void |
sort(ISortableData data)
Sorts the data in place using a randomized quick sort algorithm. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SortableDataUtils
public SortableDataUtils()
binarySearch
public static int binarySearch(ISortableData data,
int elementIndex)
- Performs a binary search for the element at the given index. The returned
index will be the first index at which the element could be inserted
without violating the sorting order. If the underlying data is not
sorted, the result is undefined. The result will be between 0 and
ISortableData.size()
inclusive. The given element index may be
larger than ISortableData.size()
, i.e. the element does not have
to be in the list.
sort
public static void sort(ISortableData data)
- Sorts the data in place using a randomized quick sort algorithm.
TUM CCSM Commons - 2.7