Reference+
Class Name
FloatList
Description
Helper class for a list of float values. Lists are designed to have some features of ArrayList, but to maintain the simplicity and efficiency of working with arrays. Functions such as sort() and shuffle() always act on the list itself. To get a sorted copy, use list.copy().sort().
Examples
FloatList inventory; void setup() { size(200, 200); inventory = new FloatList(); inventory.append(108.6); inventory.append(5.8); inventory.append(8.2); println(inventory); noLoop(); fill(0); textAlign(CENTER); } void draw() { float nums = inventory.get(2); text(nums, width/2, height/2); }
Constructors
FloatList()
FloatList(items)
Methods
size()
Get the length of the listclear()
Remove all entries from the listget()
Get an entry at a particular indexset()
Set the entry at a particular indexremove()
Remove an element from the specified indexappend()
Add a new entry to the listhasValue()
Check if a number is a part of the listadd()
Add to a valuesub()
Subtract from a valuemult()
Multiply a valuediv()
Divide a valuemin()
Return the smallest valuemax()
Return the largest valuesort()
Sorts an array, lowest to highestsortReverse()
A sort in reversereverse()
Reverse the order of the listshuffle()
Randomize the order of the list elementstoArray()
Create a new array with a copy of all the values
Related
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.