Reference+
Class Name
IntList
Description
Helper class for a list of int 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
IntList inventory; void setup() { size(200, 200); inventory = new IntList(); inventory.append(84); inventory.append(15); inventory.append(102); println(inventory); noLoop(); fill(0); textAlign(CENTER); } void draw() { int nums = inventory.get(2); text(nums, width/2, height/2); }
Constructors
IntList()
IntList(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 listincrement()
Add one to a valueadd()
Add to a valuesub()
Subtract from a valuemult()
Multiply a valuediv()
Divide a valuemin()
Return the smallest valuemax()
Return the largest valuesort()
Sorts the array, lowest to highestsortReverse()
Reverse sort, orders values from highest to lowestreverse()
Reverse the order of the list elementsshuffle()
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.