Type: List

From Waltz
Revision as of 17:29, 18 February 2019 by Patrick Angle (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The List type represents a set of data with no specific key for each value, unlike a Map.

Lists allow you to pass multiple values between nodes where otherwise only a single value would connectable.

Throughout the Waltz documentation, it is common to see a List expressed with a diamond operator as List<type>, which means that the contents of the list are expected to be of the type inside the diamond operator. Some lists may be List<Any> which is sometimes shortened to simply List.

Constructors

Arguments
List(values…) Varargs<Any> values… - A single or multiple value(s) for the list to contain. Items will be comma-separated parameters.

A List can also be created using the List Node.

Collection Access

As List is a collection type, it has special treatment for getting and setting values using the bracket notation.

To set the second value in a list named cuteThings to "puppies" you would write:

cuteThings[1] = "puppies";

Notice that the index used (1) represents the second entry in the list, as entires are 0-indexed.

To print the value present at the beginning of the list to the Console you would write:

print(cuteThings[0]);

Parameters

There are no parameters exposed by this type.

Functions

Arguments Returns Details
add(value) Any value - The value to add to the list. Boolean Adds the provided value to the end of the list.
add(index, value) Number index - The index at which to place the new value.

Any value - The value to add to the list.

Void Adds the provided value to the specified point in the list.
addAll(values) List values - The values to add to the list. Boolean Adds the provided values to the end of the list.
addAll(index, values) Number index - The index at which to place the new values.

List values - The values to add to the list.

Boolean Adds the provided values to the specified point in the list.
clear() Void Removes all of the values from the list.
contains(value) Any value - The value for which to check. Boolean Checks to see if the list contains the provided value, returning true if that is the case.
containsAll(values) List values - The values for which to check. Boolean Checks to see if this list contains all of the values in the provided list, and returns true if that is the case.
equals(list) List list - A list against which to compare equality. Boolean Compares two lists to determine if they contain identical sets of values.
get(index) Number index - The index from which to get a value. Any Get the value at the provided index.
indexOf(value) Any value - The value for which to get the index. Number Gets the index of the provided value in the list, or -1 if the value does not exist in the list.
isEmpty() Boolean Returns true if the list is empty.
remove(value) Any value - The value to remove from the list. Boolean Removes the specified value from the list, returning true if the value was present in the list.
remove(index) Number index - The index from which to remove a value. Any Removes the value from the list at the specified index, and returns that value.
removeAll(values) List values - The values to remove from the list Boolean Removes the specified list of items from this list, leaving all other items intact.
retainAll(values) List values - The values to keep in the list. Boolean Removes all items from this list not appearing in the provided list.
set(index, value) Number index - The index at which to replace the value.

Any value - The value with which to replace the value at the provided index.

Any Replaces the value at the provided index with the provided value, and returns the value previously at that index.
size() Number Returns the number of values in the list.
subList(from, to) Number from - The first index to include in the sublist.

Number to - The last index to include in the sublist.

List Returns a new list contains only the values from the from index to the to index.
Types
Primitives Boolean · Number · String
Objects Color · Dimension · DmxMultiverse · DmxUniverse · LocalInterface · Material · Point · RemoteAddress/IP · Scene · Time · Touch
Node Specific NdiSource · WoControlCue · WoHitTestResult · WoTimeline
Collections List · List of Lists · Map · Varargs
Special Any · Consumer · Expression · Null · Void