Sequences
Sequence Syntax
Sequences are variable-length collections of elements:
module M
{
sequence<Fruit> FruitPlatter;
}
A sequence can be empty — that is, it can contain no elements, or it can hold any number of elements up to the memory limits of your platform.
Sequences can contain elements that are themselves sequences. This arrangement allows you to create lists of lists:
module M
{
sequence<FruitPlatter> FruitBanquet;
}
Sequences are used to model a variety of collections, such as vectors, lists, queues, sets, bags, or trees. (It is up to the application to decide whether or not order is important; by discarding order, a sequence serves as a set or bag.)
Language Mapping
A Slice sequence maps to a native PHP indexed array. The first element of the Slice sequence is contained at index 0 (zero) of the PHP array, followed by the remaining elements in ascending index order.
Consider this example:
sequence<Fruit> FruitPlatter;
You can create an instance of FruitPlatter as shown below:
// Make a small platter with one Apple and one Orange
$platter = array(Fruit::Apple, Fruit::Orange);
The Ice runtime validates the elements of an array to ensure that they are compatible with the declared type and throws InvalidArgumentException if an incompatible type is encountered.