ArrayedCollection is an abstract class, a subclass of SequenceableCollections whose elements are held in a vector of slots. Instances of ArrayedCollection have a fixed maximum size beyond which they may not grow.
Its principal subclasses are Array (for holding objects), and RawArray, from which Int8Array, FloatArray, Signal etc. inherit.
Creates a new instance with indexedSize indexable slots. The slots are filled with Nil, zero or something else appropriate to the type of indexable slots in the object.
Create a new ArrayedCollection whose slots are filled with the given arguments.
Fill an ArrayedCollection with an arithmetic series.
Fill an ArrayedCollection with a geometric series.
Fills an ArrayedCollection with a counter. See J concepts in SC for more examples.
Return the number of elements the ArrayedCollection.
Return the maximum number of elements the ArrayedCollection can hold. For example, Arrays may initialise themselves with a larger capacity than the number of elements added.
Return the item at index.
The index can also be an Array of indices to extract specified elements. Example:
Same as -at, but values for index greater than the size of the ArrayedCollection will be clipped to the last index.
Same as -at, but values for index greater than the size of the ArrayedCollection will be wrapped around to 0.
Same as -at, but values for index greater than the size of the ArrayedCollection will be folded back.
Plot values in a GUI window. See plot for more details. When the receiver contains nil
items, the plot fails with an error.
Swap the values at indices i and j.
Put item at index, replacing what is there.
Same as -put, but values for index greater than the size of the ArrayedCollection will be clipped to the last index.
Same as -put, but values for index greater than the size of the ArrayedCollection will be wrapped around to 0.
Same as -put, but values for index greater than the size of the ArrayedCollection will be folded back.
Put the values in the corresponding indices given by keys. If one of the two argument arrays is longer then it will wrap.
Return the first index containing an item which matches item. Elements are checked for identity (not for equality).
Return a boolean indicating whether the collection contains anything matching item. Elements are checked for identity (not for equality).
Return the first index containing an item which is greater than item.
Remove and return the element at index, shrinking the size of the ArrayedCollection.
Similar to -removeAt, but does not maintain the order of the items following the one that was removed. Instead, the last item is placed into the position of the removed item and the array's size decreases by one.
Removes all items in the receiver for which the func answers true. The function is passed two arguments, the item and an integer index. Note that order is not preserved. See -takeAt.
Adds an item to an ArrayedCollection if there is space. This method may return a new ArrayedCollection. For this reason, you should always assign the result of add to a variable - never depend on add
changing the receiver.
Adds all the elements of aCollection to the contents of the receiver. This method may return a new ArrayedCollection. For this reason, you should always assign the result of addAll
to a variable - never depend on add changing the receiver.
Extends the object to match size by adding a number of items. If size is less than receiver size then truncate. This method may return a new ArrayedCollection. For this reason, you should always assign the result of extend
to a variable - never depend on add changing the receiver.
Inserts the item into the contents of the receiver.
Inserts the item into the contents of the receiver. This method may return a new ArrayedCollection. For this reason, you should always assign the result of insert
to a variable - never depend on add changing the receiver.
Moves an item from one position to another.
fromIndex |
The position in the array from which the element is removed. |
toIndex |
The position in the array before which the element is inserted again. |
Inserts the item before the contents of the receiver, possibly returning a new collection.
Remove and return the last element of the ArrayedCollection.
Increase the size of the ArrayedCollection by sizeIncrease number of slots, possibly returning a new collection.
Increase the size of the ArrayedCollection by sizeIncrease number of slots, returning a new collection with Nils in the added slots.
Return a new ArrayedCollection which is a copy of the indexed slots of the receiver from start to end. If end < start, an empty ArrayedCollection is returned.
x.copyRange(a, b)
is not equivalent to x[a..b]
. The latter compiles to -copySeries, which has different behavior when end < start.Return a new ArrayedCollection consisting of the values starting at first, then every step of the distance between first and second, up until last. If second is nil
, a step of 1 or -1 is used as appropriate.
x.copySeries(a, nil, c)
is equivalent to x[a..c]
, and x.copySeries(a, b, c)
is equivalent to x[a,b..c]
end
may be less than start
, it is not safe to use copySeries
or the shortcut syntax x[a..b]
because it will adapt to use a positive or negative step as needed. In this case, copyRange
is recommended.
Fill the receiver with an arithmetic progression. The first element will be start, the second start + step, the third start + step + step ...
Put value at every index starting at first, then every step of the distance between first and second, up until last. x.putSeries(a, b, c, val)
can also be written as x[a, b..c] = val
Concatenate the contents of the two collections into a new ArrayedCollection.
Return a new ArrayedCollection whose elements are reversed.
Iterate over the elements in order, calling the function for each element. The function is passed two arguments, the element and an index.
Iterate over the elements in reverse order, calling the function for each element. The function is passed two arguments, the element and an index.
Answer a new collection which consists of the results of function evaluated for each item in the collection. The function is passed two arguments, the item and an integer index. See Collection helpfile for examples.
The same as -collect, but can look inside sub-arrays up to the specified depth.
Interprets the array as a list of probabilities which should sum to 1.0 and returns a random index value based on those probabilities.
Returns the Array resulting from :
so that the array will sum to 1.0.
This is useful for using with windex or wchoose.
Returns a new Array with the receiver items normalized between min and max.
Returns a copy of the receiver with its items split into two equal halves, then reconstructed by interleaving the two halves.
Performs a method in place, within a certain region [from..to], returning the same array.
Rank is the number of dimensions in a multidimensional array.
For a multidimensional array, returns the number of elements along each dimension.
For a multidimensional array, rearranges the data using the desired number of elements along each dimension. The data may be extended using wrapExtend if needed.
Finds the starting index of a number of elements contained in the array. This method expects a collection as an argument. So for finding only one element, have a look at SequenceableCollection: -indexOfEqual. Elements are checked for equality (not for identity).
Return a new array in which a number of elements have been replaced by another. Elements are checked for equality (not for identity).
this method is inherited by String :
Return an integral table that can be used to generate random numbers with a specified distribution. (see Randomness helpfile for a more detailed example)
Returns a new random number from a random table.
Return the size of an osc message in bytes
Return the size of an osc bundle in bytes
For an ArrayedCollection containing numbers (e.g. audio data) this renders a plot in the post window using asterisks and spaces (works best if you use a monospace font in your post window).