Set the entry at a particular index. If the index is past the length of the list, it'll expand the list to accommodate, and fill the intermediate entries with 0s. @webref intlist:method @brief Set the entry at a particular index
(int index, int what)
| 185 | * @brief Set the entry at a particular index |
| 186 | */ |
| 187 | public void set(int index, int what) { |
| 188 | if (index >= count) { |
| 189 | data = PApplet.expand(data, index+1); |
| 190 | for (int i = count; i < index; i++) { |
| 191 | data[i] = 0; |
| 192 | } |
| 193 | count = index+1; |
| 194 | } |
| 195 | data[index] = what; |
| 196 | } |
| 197 | |
| 198 | |
| 199 | /** Just an alias for append(), but matches pop() */ |