# List (Array)

Arbor data flow supports lists (arrays).
Please use the behavior of each operation node and state for access.

## Example using a list

The following is an example of randomly extracting elements from the list set in ParameterContainer.

### GetParameter

- Added StringList parameter to graph parameters.
- Get with GetParameter.

### List.Count

- Add the List.Count operation node to get the number of elements in the string type list.

### Random.RangeInt

- Calculate the random index using the number of elements in the obtained list.

### List.GetElement

- Gets a list element by random index.

### SetParameter

- Added SelectString parameter to graph parameters.
- Set the retrieved random element in the SelectString parameter.
- Repeat at 1 second intervals with a TimeTransition to see it change randomly.

## Calculator Node

Use a calculation node to obtain various data that does not change the elements of List.

- List.Contains
- List.Count
- List.GetElement
- List.IndexOf
- List.LastIndexOf
- List.ToArrayList
- NewArrayList

## StateBehaviour

Use state behaviors to modify List elements.

- List.AddElement
- List.Clear
- List.InsertElement
- List.RemoveAtIndex
- List.RemoveElement
- List.SetElement

## Ahead-of-Time (AOT) Restrictions

Due to restrictions in the precompiled environment such as IL2CPP build, an exception will occur when using List<T> that is not referenced from the code.

See Unity - Manual: Scripting restrictions for more information on precompilation limits.

Here's how to use it that causes problems with Arbor.

- Parameter
  - AssetObjectList
  - ComponentList
  - EnumList
- List-related built-in scripts

To avoid such AOT problems, add code similar to the following.

    1
    2
    3
    4
    5
    6
    7
    using System.Collections.Generic;

    public class AOTCodeGeneration
    {
    	// For example, if you create a Foo type but List<Foo> is not used in your code.
    	public List<Foo> myStructList = new List<Foo>();
    }

You do not need to use the AOTCodeGeneration class.
Writing in a script like this will ensure that the compiler will generate the appropriate code.