The X Toolkit API

X.array

/**
* Create an array which can be sorted in-place using merge sort.
*
* @constructor
* @param {Function} comparator
* @extends X.base
*/
var a = new X.array();
/**
* The underlying array.
*
* @type {!Array}
* @protected
*/
a._array = $_ARRAY;
/**
* The className of this class.
*
* @type {string}
* @protected
*/
a._classname = $_CLASSNAME;
/**
* The void pointer to a comparator function.
*
* @type {Function}
* @protected
*/
a._comparator = $_COMPARATOR;
/**
* The 'dirty' flag of this object.
*
* @type {boolean}
* @protected
*/
a._dirty = $_DIRTY;
/**
* The uniqueId of this instance. Each class instance in XTK has a uniqueId.
*
* @type {number}
* @protected
*/
a._id = $_ID;
/**
* Get the className of this object.
*
* @return {string} The className of this object.
* @public
*/
var _classname = a.classname;
/**
* Get the id of this instance.
*
* @return {string} The className of this object.
* @public
*/
var _id = a.id;
/**
* Add an object to the array.
*
* @param {*} object The object to add.
* @return {boolean} TRUE if everything went fine.
*/
var add = a.add($OBJECT);
/**
* Completely clear the array.
*/
a.clear();
/**
* Orderly insert an element. This is part of the in-place sorting.
*
* @param {!number} begin The start index.
* @param {!number} end The end index.
* @param {*} v The value/object to insert.
*/
a.insert_($BEGIN, $END, $V);
/**
* Merge component of the in-place sorting.
*
* @param {!number} begin The start index.
* @param {!number} begin_right The start index from the right.
* @param {!number} end The end index.
*/
a.merge_inplace_($BEGIN, $BEGIN_RIGHT, $END);
/**
* Recursive function to perform in-place merge sort.
*
* @param {!number} begin The start index.
* @param {!number} end The end index.
*/
a.msort_($BEGIN, $END);
/**
* Start the in-place merge sort on the complete array.
*/
a.sort();
/**
* Swap two elements in the array.
*
* @param {!number} index1 Index of element1.
* @param {!number} index2 Index of element2.
*/
a.swap_($INDEX1, $INDEX2);
/**
* Get the complete array.
*
* @return {!Array} The complete array.
*/
var values = a.values();


CONSTRUCTORS
X.array

PROPERTIES
_array
_classname
_comparator
_dirty
_id

GETTERS/SETTERS
classname
id

FUNCTIONS
add
clear
insert_
merge_inplace_
msort_
sort
swap_
values

STATIC



SOURCECODE