Skip to main content

Lists

In feature programming it is often useful to store data in lists. An FObjectlist is used as a container and can store any kind of object types. When accessing an object from an objectlist you can use the command .at(index) to access the object at a specified index location in the list. Since CAESES only knows that the list entry is an "object" you need to cast the object to the desired type you want to continue working with. Make sure to read the Effective Feature Programming to learn more about the casting of objects and the castTo() command.

Index starts at 0

The first element of a list can be found with the index 0 via objectlist.at(0).

If you would like to access the last element of an objectlist you need to check for the number of entries the list has. You can use the command .getSize() to find out how many objects are stored in the list. Since we are starting to count from index 0 you can access the last element of your list with objectlist.getSize()-1.

Check the type documentation for more useful commands.

Combining Lists

To concatenate lists you can make use of a typed list that allows to link two or more lists together and combine them into one list. You can use the .add() command to concatenate lists, like shown in the example code below.

FList<Double> a([1,2,3])
FList<Double> b([4,5,6])

FList<Double> c()
c.add(a)
c.add(b)

// results in
// c = [1,2,3,4,5,6]