Package com.blackrook.rookscript
Class ScriptValue.ListType
java.lang.Object
com.blackrook.rookscript.ScriptValue.ListType
- All Implemented Interfaces:
Iterable<ScriptIteratorType.IteratorPair>
- Enclosing class:
- ScriptValue
public static class ScriptValue.ListType
extends Object
implements Iterable<ScriptIteratorType.IteratorPair>
The class used for a list/set.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int index, ScriptValue value) Adds an item to the list and expands its size by one.void
add
(ScriptValue value) Adds an item to the list and expands its size by one.void
get
(int index, ScriptValue out) Gets a value from the list at an index.int
indexOf
(ScriptValue value) Finds a script value sequentially (strict equals).boolean
isEmpty()
iterator()
int
lastIndexOf
(ScriptValue value) Finds a script value sequentially, in reverse (strict equals).boolean
remove
(ScriptValue value) Finds an object and removes it from the list.boolean
removeIndex
(int index, ScriptValue out) Removes an object at an index.int
search
(ScriptValue value) Binary searches for a value.void
Sets a value from the list at an index.void
setSize
(int size) Sets the size of the list.int
size()
void
sort()
Sorts this array.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
setSize
public void setSize(int size) Sets the size of the list.- Parameters:
size
- the new size.
-
add
Adds an item to the list and expands its size by one.- Parameters:
value
- the value to add.
-
add
Adds an item to the list and expands its size by one.- Parameters:
index
- the index to add it to.value
- the value to add.
-
indexOf
Finds a script value sequentially (strict equals).- Parameters:
value
- the values.- Returns:
- the index of the found value or -1 if not found.
-
lastIndexOf
Finds a script value sequentially, in reverse (strict equals).- Parameters:
value
- the values.- Returns:
- the index of the found value or -1 if not found.
-
removeIndex
Removes an object at an index.- Parameters:
index
- the index.out
- the output value, set to the removed value.- Returns:
- true if a value was removed, false if not (index was out of range).
-
remove
Finds an object and removes it from the list.- Parameters:
value
- the value to remove.- Returns:
- true if removed, false if not.
-
get
Gets a value from the list at an index.- Parameters:
index
- the provided index.out
- the output value, set to the desired value.
-
set
Sets a value from the list at an index.- Parameters:
index
- the provided index.value
- the value to set.
-
sort
public void sort()Sorts this array. -
search
Binary searches for a value.- Parameters:
value
- the value to search for.- Returns:
- the index of the found value or < 0.
-
size
public int size()- Returns:
- the size of this list in items.
-
isEmpty
public boolean isEmpty()- Returns:
- true if this list is empty, false otherwise.
-
iterator
- Specified by:
iterator
in interfaceIterable<ScriptIteratorType.IteratorPair>
-
toString
-