#include <coherence/util/Arrays.hpp>
Static Public Member Functions | |
static void | copy (ObjectArray::Handle haoSrc, size32_t iSrcStart, ObjectArray::Handle haoDest, size32_t iDestStart, size32_t cElements) |
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array. | |
static void | reverse (ObjectArray::Handle hao) |
Reverses the order of the elements in the specified array. | |
static void | sort (ObjectArray::Handle hao, Comparator::Handle hComparator=NULL) |
Sorts the specified array of objects according to the order induced by the specified comparator. | |
static void | swap (ObjectArray::Handle hao, size32_t i, size32_t j) |
Swaps the elements at the specified positions in the specified array. | |
static int32_t | binarySearch (ObjectArray::View vaoSorted, Object::View vo, Comparator::View vComparator=NULL) |
Performs a binary search for the specified element in the specified sorted array using the Comparator to compare elements. | |
static int32_t | binarySearch (ObjectArray::View vaoSorted, size32_t iStart, size32_t iEnd, Object::View vo, Comparator::View vComparator=NULL) |
Performs a binary search for the specified element in a part of the specified sorted array using the Comparator to compare elements. | |
static List::View | asList (ObjectArray::View vao) |
Returns a fixed-size list backed by the specified array. |
static void copy | ( | ObjectArray::Handle | haoSrc, | |
size32_t | iSrcStart, | |||
ObjectArray::Handle | haoDest, | |||
size32_t | iDestStart, | |||
size32_t | cElements | |||
) | [static] |
Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array.
haoSrc | the source array | |
iSrcStart | starting position in the source array | |
haoDest | the destination array | |
iDestStart | starting position in the destination data | |
cElements | the number of array elements to be copied |
IndexOutOfBoundsException | if copying would cause access of data outside array bounds |
static void reverse | ( | ObjectArray::Handle | hao | ) | [static] |
Reverses the order of the elements in the specified array.
This method runs in linear time.
hao | the array whose elements are to be reversed. |
static void sort | ( | ObjectArray::Handle | hao, | |
Comparator::Handle | hComparator = NULL | |||
) | [static] |
Sorts the specified array of objects according to the order induced by the specified comparator.
All elements in the array must be mutually comparable by the specified comparator.
This sort is guaranteed to be stable: equal elements will not be reordered as a result of the sort.
hao | the array to be sorted | |
hComparator | the comparator to determine the order of the array. A null value indicates that the elements' natural ordering should be used |
ClassCastException | if the array contains elements that are not mutually comparable |
static void swap | ( | ObjectArray::Handle | hao, | |
size32_t | i, | |||
size32_t | j | |||
) | [static] |
Swaps the elements at the specified positions in the specified array.
(If the specified positions are equal, invoking this method leaves the array unchanged.)
hao | the array in which to swap elements. | |
i | the index of one element to be swapped. | |
j | the index of the other element to be swapped. |
IndexOutOfBoundsException | if either i or j is out of range (i < 0 || i >= hList->length || j < 0 || j >= hList->length). |
static int32_t binarySearch | ( | ObjectArray::View | vaoSorted, | |
Object::View | vo, | |||
Comparator::View | vComparator = NULL | |||
) | [static] |
Performs a binary search for the specified element in the specified sorted array using the Comparator to compare elements.
vaoSorted | the sorted Object array to search | |
vo | the value element to find | |
vComparator | the Comparator (optional) |
static int32_t binarySearch | ( | ObjectArray::View | vaoSorted, | |
size32_t | iStart, | |||
size32_t | iEnd, | |||
Object::View | vo, | |||
Comparator::View | vComparator = NULL | |||
) | [static] |
Performs a binary search for the specified element in a part of the specified sorted array using the Comparator to compare elements.
vaoSorted | the sorted Object array to search | |
iStart | the inclusive start index | |
iEnd | the exclusive end index | |
vo | the value element to find | |
vComparator | the Comparator (optional) |
static List::View asList | ( | ObjectArray::View | vao | ) | [static] |
Returns a fixed-size list backed by the specified array.
(Changes to the returned list "write through" to the array.) This method acts as bridge between array-based and collection-based APIs. This method also provides a convenient way to create a fixed-size list initialized to contain several elements:
vao | the array by which the list will be backed |