List and EList types

The EGL List type is a reference type that provides a type-specific dynamic array. In Eclipse IDE for EGL Developers, the type definition for List is EList.

EGL package name

eglx.lang

Example use
Type detail
In the following detail, the Operation annotation indicates that the specified operation is available. For example, use “==” to compare two values, not “$EQ”. Two exceptions are the widen and narrow operations, which are invoked during data conversions; for example, when the as operator is used.
/**
 * EList defines the API of lists (dynamically-sized arrays) in EGL.  
 * Lists have a size, which is the number of elements they contain.  
 * The size may be zero.
 */
externalType EList type ClassType {  
   typeParameters = ["E"] }

/**
	 * {@Operation +} Creates a new list consisting of the first operand's elements
	 * followed by the second operand.  The assigning form of the operator (+=) does 
	 * not create a new list: the appendElement function is used to add the second 
	 * operand to the end of the first operand.
	 */
static function $Plus(lvalue EList in, rvalue EAny in) 
       returns (EList) {@Operation{"+"}};

/**
	 * {@Operation ::} Creates a new list consisting of the first operand's elements
	 * followed by the second operand.  The assigning form of the operator (::=) does 
	 * not create a new list: the appendElement function is used to add the second 
	 * operand to the end of the first operand.
	 */
static function $Concat(value EList in, rvalue EAny in) 
       returns (EList) {@Operation{"::"}};

/**
	 * {@Operation +} Creates a new list consisting of the first operand followed 
	 * by the second operand's elements.  The assigning form of the operator (+=) does
	 * not create a new list: the insertElement function is used to add the second
	 * operand to the front of the first operand.
	 */
static function $Plus(lvalue EAny in, rvalue EList in) 
       returns (EList) {@Operation{"+"}};

/**
	 * {@Operation ::} Creates a new list consisting of the first operand followed 
	 * by the second operand's elements.  The assigning form of the operator (::=) does
	 * not create a new list: the insertElement function is used to add the second
	 * operand to the front of the first operand.
	 */
static function $Concat(value EAny in, rvalue EList in) 
       returns (EList) {@Operation{"::"}};

/**
	 * {@Operation +} Creates a new list consisting of the first operand's elements
	 * followed by the second operand's elements.  The assigning form of the operator
	 * (+=) does not create a new list: the appendAll function is used to add the 
	 * second operand's elements to the end of the first operand.
	 */
static function $Plus(lvalue EList in, rvalue EList in) 
       returns (EList) {@Operation{"+"}};

/**
	 * {@Operation ::} Creates a new list consisting of the first operand's elements
	 * followed by the second operand's elements.  The assigning form of the operator
	 * (::=) does not create a new list: the appendAll function is used to add the 
	 * second operand's elements to the end of the first operand.
	 */
static function $Concat(value EList in, rvalue EList in) 
       returns (EList) {@Operation{"::"}};

/**
	 * {@Operation []} Returns the element at the specified index.
	 * @throws InvalidIndexException  if the index is less than 1 or greater than the size.
	 */
static function $Get(value EList in, index EInt in) 
       returns(EAny) {@Operation{"[]"}};
	
/**
	 * Adds an element to the end of this list.
	 *
	 * @param element  the new element.
	 * @return this list, after the new element has been added.
	 */
function appendElement(element EAny in) returns(EList);
	
/**
	 * Adds the elements of the specified list to the end of this list.
	 *
	 * @param other  the other list.
	 * @return this list, after the new elements have been added.
	 */
function appendAll(other EList in) returns(EList);
	
/**
	 * Inserts an element into this list at a specified position.  Any elements
	 * at or beyond the specified index are shifted toward the end.
	 *
	 * The index may be any valid position within this list.  It may also be 
	 * zero, indicating that the new element goes at the front, or it may be one
	 * more than the current size, indicating that the new element goes at the 
	 * end (as if appendElement had been called). 
	 *
	 * @param element  the new element.
	 * @param index  where the element should be added.
	 * @throws InvalidIndexException  if the index is negative or greater than 1 plus the size.
	 */
function insertElement(element EAny in, index EInt in);
	
/**
	 * Removes the element at a specified position from this list.  Any elements
	 * at or beyond the specified index are shifted toward the front.
	 *
	 * @param index  where the element should be removed.
	 * @throws InvalidIndexException  if the index isn't a valid subscript.
	 */
function removeElement(index EInt in);

/**
	 * Returns the index of the first ocurrance of the specified value within 
	 * the list.  The search begins at the specified index and stops at the
	 * end of the list.
	 * 
	 * @param value  the value to find.
	 * @param index  the index of the element to examine first. 
	 * @return the index of the value, or 0 if it was not found.
	 * @throws InvalidIndexException  if the index isn't a valid subscript.
	 */
function indexOfElement(value EAny in, index EInt in) returns(EInt);

/**
	 * This is equivalent to indexOfElement(element, 1).
	 * 
	 * @param value the value to find.
	 * @return the index of the value, or 0 if it was not found.
	 */
function indexOfElement(value EAny in) returns(EInt);
	
/**
	 * Removes all elements from the list.
	 */
function removeAll();
	
/**
	 * Sets the value of an element.
	 *
	 * @param value  the value for the specified element.
	 * @param index  the index of the element to be updated. 
	 * @throws InvalidIndexException  if the index isn't a valid subscript.
	 */
function setElement(value EAny in, index EInt in);

/**
	 * Returns the current size of the list.
	 *
	 * @return the current size of the list.
	 */
function getSize() returns(EInt);

/**
	 * Changes the size of the list.  If the new size is greater than the current
	 * size, new elements are added at the end of the list.  If the new size is
	 * smaller than the current size, elements at the end are removed. 
	 *
	 * @param size  the new size.
	 * @throws InvalidSizeException  if the specified size is negative.
	 */
function resize(size EInt in);

/**
	 * Sorts the elements of the list in order from smallest to largest.
	 *
	 * @param sortFunction  a function capable of comparing two elements.
	 * @throws InvocationException when the sort function can't be called.
	 */
function sort(sortFunction SortFunction in);
end

/**
 * The delegate used by EList.sort() to compare elements.
 *
 * @param a  the first value.
 * @param b  the second value.
 * @return zero if a == b, a positive number if a > b, or a negative number if a < b.
 */
Delegate
   SortFunction(a any in, b any in) returns (int)
end
Comments
The array has an identity independent of its elements.
Compatibility
Table 1. Compatibility
Target Issue
Java No issues.
JavaScript No issues.