Collections and Lists

DataMixer gets its values by iterating over collections of data. A collection is an unordered group of elements. Example collections are building names or city names. A list is an ordered collection. Example lists are the integers, or the names of months.

Some collections are concrete (i.e. a set of strings read from a file), and some are synthetic. The latter are usually used to model collections of primitive datatypes. This is because it may be easier, or save space, to generate numbers and other simple types rather than store instances of them in a collection. The standard datatypes (boolean, char, short, int, float, double, string, date, etc.) are supported.

A range defines the first and last values (bounds) of a synthetic collection, and possibly its increment. First and last values are placed between parens or square brackets: a parenthesis indicates an open bound; a square bracket a closed bound. The increment, if there is one, follows the closing parenthesis or bracket.

For example, these ranges generate these values:

  • [first,last]step generates values that start with first and end with last. Each next value increments by step. For example, [10,20]3 generates 10,13,16,19.
  • [first]step generates values that start with first and have no upper bound. Each next value increments by step. For example, [10]2 generates 10,12,14,...
  • [first] is the same as [first]step with step=1.
  • [] is the same as [first], with first = 0.

The notation for ranges is:

    Range       ::= OpenBound First (',' Last)? CloseBound Increment?
    OpenBound   ::= '(' | '['
    CloseBound  ::= ')' | ']'
    First       ::= Value
    Last        ::= Value
    Increment   ::= Value
    Value       ::= datatype instance
  

For example:

XML
Generates
<ints>Integers, starting at 0, incrementing by 1, with no upper bound.
<ints range="[22]">Integers, starting at 22, incrementing by 1, with no upper bound.
<ints range="[22]-1">Integers, starting at 22, decrementing by 1, with no lower bound.
<ints range="[0,10)">10 integers, numbered 0-9.
<ints range="[0,10]2">6 integers: 0, 2, 4, 6, 8, 10.
<ints range="[10,-1]-5">3 integers: 10, 5, 0.