Name

Class xbArray — implements cross browser Array

Synopsis

extends Class xbObject

class xbArray : xbObject
{ 
  // constructor 
  xbArray(); 
     
  // methods 
  void     destroy();
  Object   item(Integer index); 
  xbArray  concat(xbArray xbarray); 
  String   join(String delimiter); 
  Object   pop(); 
  Object   push(Object obj); 
  Object   top();
  xbArray  reverse(); 
  Object   shift(); 
  Integer  unshift(Object obj); 
  xbArray  slice(Integer startIndex, Integer stopIndex); 
  xbArray  sort(Function cmp);
  Integer  getLength(); 
     
  // properties 
  Array    list; 
  Integer  length; 
}
		

Source

xbArray.js

Description

xbArray is meant as a portable replacement for the built in Javascript Class Array since the implementations of Array still differ between IE and Mozilla.

Properties

list

readonly Array - Reference to the native Javascript Array used to implement the xbArray.

length

readonly Integer - Number of items currently in the xbArray.

Methods

xbArray()

Constructs an instance of the xbArray class

Returns. Nothing

Exceptions

  • None

destroy()

Overrides xbObject.destroy. Destroys this instance of xbArray. If the objects contained in the xbArray have destroy methods defined, they will be called before the xbArray is destroyed.

Returns.  Nothing

Exceptions

  • None

item(Integer index)

Return a reference to the index-th object contained in the xbArray. Returns null if index is not a valid position in the xbArray. index ranges from 0 to length - 1.

Returns.  Object at offset index or null if index is not a valid offset.

Exceptions

  • None

concat(xbArray array)

Create and return a new xbArray with the xbArray array concatenated to the end. This does not change the original xbArray.

Returns.  xbArray

Exceptions

  • None

join(String delimiter)

Return a string constructed by joining the elements of the xbArray together with the String delimiter as delimiter.

Returns.  String

Exceptions

  • None

pop()

Remove and return the last element of the xbArray of null if the xbArray is empty.

Returns.  Object

Exceptions

  • None

push(Object obj)

places the object obj at the end of the xbArray and returns a reference to it.

Returns.  Object Reference to object pushed onto the xbArray

Exceptions

  • None

top()

Returns a reference to the element at the end of the xbArray without removing it from the xbArray. If the xbArray is empty, top() returns null.

Returns.  Object

Exceptions

  • None

reverse()

reverses the xbArray's elements and returns a reference to itself.

Returns.  xbArray

Exceptions

  • None

shift()

Removes the first element from the xbArray and returns a reference to it or null if there is no element.

Returns.  Object

Exceptions

  • None

unshift(Object obj)

inserts object obj in the front of the array and returns the new length of the xbArray.

Returns.  Integer new length of xbArray

Exceptions

  • None

slice(Integer startIndex, Integer stopIndex)

returns a xbArray consisting of the elements from startIndex to stopIndex.

Returns.  xbArray

Exceptions

  • None

sort(Function cmp)

returns a sorted copy of the xbArray using the comparison function cmp(left, right) function.

cmp(left, right) compares left to the right and returns -1 if left is less than right; 0 if left is equal to right; and +1 if left is greater than right.

Returns.  xbArray

Exceptions

  • None

getLength()

Return the length of the xbArray (same as length).

Returns.  Integer

Exceptions

  • None