ArrayedCollection:
Filter:
Classes | Collections > Ordered

ArrayedCollection : SequenceableCollection : Collection : Object

Abstract superclass of Collections of fixed maximum size
Subclasses: Array, RawArray

Description

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.

Class Methods

ArrayedCollection.newClear(indexedSize: 0)

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.

ArrayedCollection.with( ... args)

From superclass: Collection

Create a new ArrayedCollection whose slots are filled with the given arguments.

ArrayedCollection.series(size, start: 0, step: 1)

From superclass: SequenceableCollection

Fill an ArrayedCollection with an arithmetic series.

ArrayedCollection.geom(size, start, grow)

From superclass: SequenceableCollection

Fill an ArrayedCollection with a geometric series.

ArrayedCollection.iota( ... sizes)

Fills an ArrayedCollection with a counter. See J concepts in SC for more examples.

Inherited class methods

Instance Methods

.size

Return the number of elements the ArrayedCollection.

.maxSize

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.

.at(index)

Return the item at index.

The index can also be an Array of indices to extract specified elements. Example:

.clipAt(index)

Same as -at, but values for index greater than the size of the ArrayedCollection will be clipped to the last index.

.wrapAt(index)

Same as -at, but values for index greater than the size of the ArrayedCollection will be wrapped around to 0.

.foldAt(index)

Same as -at, but values for index greater than the size of the ArrayedCollection will be folded back.

.plot(name, bounds, discrete: false, numChannels, minval, maxval, separately: true)

From extension in /usr/local/share/SuperCollider/SCClassLibrary/Common/GUI/PlusGUI/Math/PlotView.sc

Plot values in a GUI window. See plot for more details. When the receiver contains nil items, the plot fails with an error.

.swap(i, j)

Swap the values at indices i and j.

.put(index, item)

Put item at index, replacing what is there.

.clipPut(index, item)

Same as -put, but values for index greater than the size of the ArrayedCollection will be clipped to the last index.

.wrapPut(index, item)

Same as -put, but values for index greater than the size of the ArrayedCollection will be wrapped around to 0.

.foldPut(index, item)

Same as -put, but values for index greater than the size of the ArrayedCollection will be folded back.

.putEach(keys, values)

Put the values in the corresponding indices given by keys. If one of the two argument arrays is longer then it will wrap.

.indexOf(item)

Return the first index containing an item which matches item. Elements are checked for identity (not for equality).

.includes(item)

Return a boolean indicating whether the collection contains anything matching item. Elements are checked for identity (not for equality).

.indexOfGreaterThan(val)

Return the first index containing an item which is greater than item.

.removeAt(index)

Remove and return the element at index, shrinking the size of the ArrayedCollection.

.takeAt(index)

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.

.takeThese(func)

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.

.add(item)

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.

.addAll(aCollection)

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.

.extend(size, item)

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.

.fill(value)

Inserts the item into the contents of the receiver.

NOTE: the difference between this and Collection's *fill.

.insert(index, item)

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.

.move(fromIndex, toIndex)

Moves an item from one position to another.

Arguments:

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.

.addFirst(item)

Inserts the item before the contents of the receiver, possibly returning a new collection.

.pop

Remove and return the last element of the ArrayedCollection.

.grow(sizeIncrease)

Increase the size of the ArrayedCollection by sizeIncrease number of slots, possibly returning a new collection.

.growClear(sizeIncrease)

Increase the size of the ArrayedCollection by sizeIncrease number of slots, returning a new collection with Nils in the added slots.

.copyRange(start, end)

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.

WARNING: x.copyRange(a, b) is not equivalent to x[a..b]. The latter compiles to -copySeries, which has different behavior when end < start.

.copySeries(first, second, last)

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]

NOTE: If the intent is to copy forward in an array, and you are calculating start and end indices such that 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.

.seriesFill(start, step)

Fill the receiver with an arithmetic progression. The first element will be start, the second start + step, the third start + step + step ...

.putSeries(first, second, last, value)

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

++(anArray)

Concatenate the contents of the two collections into a new ArrayedCollection.

.reverse

Return a new ArrayedCollection whose elements are reversed.

.do(function)

Iterate over the elements in order, calling the function for each element. The function is passed two arguments, the element and an index.

.reverseDo(function)

Iterate over the elements in reverse order, calling the function for each element. The function is passed two arguments, the element and an index.

.collect(function)

From superclass: Collection

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.

.deepCollect(depth: 1, function, index: 0, rank: 0)

The same as -collect, but can look inside sub-arrays up to the specified depth.

.windex

Interprets the array as a list of probabilities which should sum to 1.0 and returns a random index value based on those probabilities.

.normalizeSum

Returns the Array resulting from :

so that the array will sum to 1.0.

This is useful for using with windex or wchoose.

.normalize(min: 0.0, max: 1.0)

Returns a new Array with the receiver items normalized between min and max.

.perfectShuffle

Returns a copy of the receiver with its items split into two equal halves, then reconstructed by interleaving the two halves.

NOTE: use an even number of item pairs in order to not loose any items in the shuffle.

.performInPlace(selector, from, to, argList)

Performs a method in place, within a certain region [from..to], returning the same array.

.rank

Rank is the number of dimensions in a multidimensional array.

.shape

For a multidimensional array, returns the number of elements along each dimension.

.reshape( ... shape)

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.

.find(sublist, offset: 0)

From superclass: SequenceableCollection

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).

.replace(find, replace)

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 :

.asRandomTable(size)

Return an integral table that can be used to generate random numbers with a specified distribution. (see Randomness helpfile for a more detailed example)

.tableRand

Returns a new random number from a random table.

.msgSize

Return the size of an osc message in bytes

.bundleSize

Return the size of an osc bundle in bytes

.asciiPlot

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).

Inherited instance methods

Undocumented instance methods

.addIfNotNil(item)

.asArray

.atDec(index, dec: 1)

.atInc(index, inc: 1)

.atModify(index, function)

.bubble(depth: 0, levels: 1)

.clipExtend(length)

.clumpBundles

.deepDo(depth: 1, function, index: 0, rank: 0)

.fft(imag: 0)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/wslib/wslib-classes/Lang/Shortcuts/extArray-fft.sc

.getSlots

.ifft(imag: 0)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/wslib/wslib-classes/Lang/Shortcuts/extArray-fft.sc

.indexedSize

.isArray

.normalize2(max: 1.0)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/Collection/extCollection-normalize2.sc

.overWrite(aCollection, pos: 0)

.prBundleSize

.preExtend(size, item)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/String/asStringWithFrac.sc

.reshapeLike(another, indexing: 'wrapAt')

.setSlots(array)

.slice( ... cuts)

.slotAt(index)

.slotIndex(key)

.slotKey(index)

.slotPut(index, value)

.slotSize

.toBuffer(buffer)

From extension in /home/stefan/.local/share/SuperCollider/downloaded-quarks/JITLibExtensions/classes/extBufEnvir.sc

.unbubble(depth: 0, levels: 1)