namespace Array

Provides a set of functions to manipulate arrays

namespace attributes [NB. highlighted items are covered in other pages - namespaces or classes]
function size() - Returns the number of items that are in an array
function keys() - Returns an array of strings representing the keys in the array
function push() - Pushes a variable onto the end of an array
function pop() - Pops a variable from the end of an array
function unshift() - Shifts a variable onto the start of an array
function shift() - Shifts a variable from the start of an array
function del() - Deletes an item from an array
function getIndex() - Finds the index number of an array item from its key string
function getName() - Finds the key string of an array item
function print() - Dumps an array to stdout
function keyExists() - Discovers whether there is an item with a particular key in an array
function valueExists() - Discovers whether there is an item with a particular value in an array
function join() - Converts an array to a string with a specified string between the items
function combine() - Combines two arrays into a single array
function find() - Locates an item in an array by value and returns its index number
function intersect() - Calculates the intersection of two arrays
function union() - Calculates the union of two arrays
function subtract() - Subtracts array b from array a

Functions

function size Click to go up to the list
Returns the number of items that are in an array
Declaration:
    native function size( array a )
Parameters:
    Parameter #1: array a - The array
Returns:
    The number of items that are in the array

function keys Click to go up to the list
Returns an array of strings representing the keys in the array
Declaration:
    native function keys( array a )
Description:
This function returns an array of the key strings which are present in the specified array. Note that the returned array is in hash order (which is basically random), not in the same order as the array that was passed in.
Parameters:
    Parameter #1: array a - The array
Returns:
    An array containing the key strings

function push Click to go up to the list
Pushes a variable onto the end of an array
Declaration:
    native function push( array a, void var )
Parameters:
    Parameter #1: array a - The array to push the variable onto
    Parameter #2: void var - The variable to push onto the end of the array

function pop Click to go up to the list
Pops a variable from the end of an array
Declaration:
    native function pop( array a )
Parameters:
    Parameter #1: array a - The array to pop a variable from
Returns:
    The variable which was popped from the end of the array

function unshift Click to go up to the list
Shifts a variable onto the start of an array
Declaration:
    native function unshift( array a, void var )
Parameters:
    Parameter #1: array a - The array to shift a variable onto
    Parameter #2: void var - The variable to shift onto the start of the array

function shift Click to go up to the list
Shifts a variable from the start of an array
Declaration:
    native function shift( array a )
Parameters:
    Parameter #1: array a - The array to shift a variable from
Returns:
    The variable which was shifted from the start of the array

function del Click to go up to the list
Deletes an item from an array
Declaration:
    native function del( array a, void var )
Description:
This function deletes an item from the specified array, if it exists. The var parameter can be either the index number or the key string of the item to delete.
Parameters:
    Parameter #1: array a - The array to delete an item from
    Parameter #2: void var - The index or key of the item to delete

function getIndex Click to go up to the list
Finds the index number of an array item from its key string
Declaration:
    native function getIndex( array a, string var )
Parameters:
    Parameter #1: array a - The array
    Parameter #2: string var - The key string
Returns:
    The index of the array item, or -1 on failure

function getName Click to go up to the list
Finds the key string of an array item
Declaration:
    native function getname( array a, number index )
Parameters:
    Parameter #1: array a - The array
    Parameter #2: number index - The index of the array item
Returns:
    The key string of the item, or an empty string on failure

function print Click to go up to the list
Dumps an array to stdout
Declaration:
    native function print( array vars )
Description:
This is a debugging function used to dump an array directly to stdout, bypassing the Console system, and as such should not normally be used.
Parameters:
    Parameter #1: array vars - The array to dump

function keyExists Click to go up to the list
Discovers whether there is an item with a particular key in an array
Declaration:
    native function keyExists( array a, string key )
Parameters:
    Parameter #1: array a - The array
    Parameter #2: string key - The key string to look for
Returns:
    True if it exists, false if it does not

function valueExists Click to go up to the list
Discovers whether there is an item with a particular value in an array
Declaration:
    native function valueExists( array a, void value )
Parameters:
    Parameter #1: array a - The array
    Parameter #2: void value - The value to look for
Returns:
    True if it exists, false if it does not

function join Click to go up to the list
Converts an array to a string with a specified string between the items
Declaration:
    native function join( array a, string value )
Parameters:
    Parameter #1: array a - The array to convert into a string
    Parameter #2: string value - A delimiting string to place between each pair of array items
Returns:
    A string representation of the array

function combine Click to go up to the list
Combines two arrays into a single array
Declaration:
    function combine( array keys, array values )
Description:
Combines the specified arrays into a single array, where the strings in the keys array are used as keys to the values from the values array. In the case of duplicate keys, the last one in the array is used. If the arrays are not the same size, the combination stops when the end of the shortest array is reached. Any keys which are not strings are ignored.
Parameters:
    Parameter #1: array keys - The key strings
    Parameter #2: array values - The variables associated with the keys
Returns:
    An array containing the specified keys and values

function find Click to go up to the list
Locates an item in an array by value and returns its index number
Declaration:
    function find(array a, string var)
Parameters:
    Parameter #1: array a - The array to search through
    Parameter #2: string var - The value of the item to search for
Returns:
    The index of the array item, or -1 if no match was found.

function intersect Click to go up to the list
Calculates the intersection of two arrays
Declaration:
    function intersect( array a, array b )
Description:
This function calculates the intersection of the two input arrays. The output array contains only keys which are in both of the input arrays. The values associated with the items in the output array are taken from array a. If there aren't any intersecting keys, the returned array will be empty.
Parameters:
    Parameter #1: array a - The first array, which the values are taken from
    Parameter #2: array b - The second array
Returns:
    An array containing only keys which are in both input arrays

function union Click to go up to the list
Calculates the union of two arrays
Declaration:
    function union( array a, array b )
Description:
This function unifies the two input arrays, producing a single output array containing one item for each of the keys that is in the input arrays. Where a key is present in both input arrays, the value is taken from array a. Items which don't have keys are dropped.
Parameters:
    Parameter #1: array a - The first array, which the values are taken from
    Parameter #2: array b - The second array
Returns:
    An array containing one of each key that is in the two sets

function subtract Click to go up to the list
Subtracts array b from array a
Declaration:
    function subtract( array a, array b )
Description:
This function removes any items from array a which have the same key as an item in array b. Items which don't have keys are dropped.
Parameters:
    Parameter #1: array a - The minuend
    Parameter #2: array b - The subtrahend
Returns:
    An array containing all the keys which are in a but not b

Automatically generated at 8:45pm, Wednesday 08 January 2003 by feritedoc.