Array:
Filter:
Classes | Collections > Ordered

Array : ArrayedCollection : SequenceableCollection : Collection : Object

fixed size collection
Source: Array.sc
Subclasses: Matrix, NFunc, SystemNFunc

Description

Arrays are ArrayedCollections whose slots may contain any object. Arrays have a fixed maximum size beyond which they cannot grow. For expandable arrays, use the List class.

Literal Arrays can be created at compile time, and are very efficient. See Literals for information.

For handling multidimensional arrays, there are specific methods which are covered in the helpfile J concepts in SC.

NOTE: For Arrays, the add method may or may not return the same Array object. It will add the argument to the receiver if there is space, otherwise it returns a new Array object with the argument added. Thus the proper usage of add with an Array is to always assign the result as follows:

This allows an efficient use of resources, only growing the array when it needs to. The List class manages the Array internally, and in many cases is more suitable.

Elements can be put into an existing slot with a.put(2,obj) and accessed with a.at(2) or a[2]

See ArrayedCollection for the principal methods: at, put, clipAt, wrapAt, etc...

Class Methods

Array.new(maxSize: 0)

From superclass: Object

Create a new array with size 0 that can grow up to the fixed size.

Arguments:

maxSize

The maximum size of the array.

Array.newClear(indexedSize: 0)

From superclass: ArrayedCollection

Create a new array with all slots filled with nils.

Arguments:

indexedSize

The size of the array.

Array.with( ... args)

Create a new Array whose slots are filled with the given arguments. This is the same as the method in ArrayedCollection, but is reimplemented here to be more efficient.

Array.fill(size, function)

From superclass: Collection

Creates a Collection of the given size, the elements of which are determined by evaluation the given function. The function is passed the index as an argument.

Arguments:

size

The size of the collection which is returned. If nil, it returns an empty collection. If an array of sizes is given, the resulting collection has the appropriate dimensions (see: *fillND).

function

The function which is called for each new element - the index is passed in as a first argument. The function be anything that responds to the message "value".

Array.fill2D(rows, cols, function)

From superclass: Collection

Creates a 2 dimensional Collection of the given sizes. The items are determined by evaluation of the supplied function. The function is passed row and column indexes as arguments. See J concepts in SC

Array.fillND(dimensions, function, args: [ ])

From superclass: Collection

Creates a N dimensional Collection where N is the size of the array dimensions. The items are determined by evaluation of the supplied function. The function is passed N number of indexes as arguments. See J concepts in SC

Array.newFrom(aCollection)

From superclass: Collection

Creates a new Collection from another collection. This supports the interface for the method "as".

Array.geom(size, start, grow)

From superclass: SequenceableCollection

Fill an ArrayedCollection with a geometric series.

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

From superclass: SequenceableCollection

Fill an ArrayedCollection with an arithmetic series.

Array.iota( ... sizes)

From superclass: ArrayedCollection

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

Array.interpolation(size, start: 0.0, end: 1.0)

From superclass: SequenceableCollection

Fill a SequenceableCollection with the interpolated values between the start and end values.

Array.rand(size, minVal, maxVal)

From superclass: SequenceableCollection

Fill a SequenceableCollection with random values in the range minVal to maxVal.

Array.rand2(size, val)

From superclass: SequenceableCollection

Fill a SequenceableCollection with random values in the range -val to +val.

Array.linrand(size, minVal, maxVal)

From superclass: SequenceableCollection

Fill a SequenceableCollection with random values in the range minVal to maxVal with a linear distribution.

Array.exprand(size, minVal, maxVal)

From superclass: SequenceableCollection

Fill a SequenceableCollection with random values in the range minVal to maxVal with exponential distribution.

Array.fib(size, a: 0.0, b: 1.0)

From superclass: SequenceableCollection

Fill a SequenceableCollection with a fibonacci series.

Arguments:

size

the number of values in the collection

a

the starting step value

b

the starting value

Array.zeroFill(size)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/SignalBox/Classes/extArray.sc

Create a new array with all slots filled with 0.0.

Array.regularPolygon(size: 3, orientation: 0.0, wrap: 6.2831853071796)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/atk-sc3/Classes/extArray.sc

Fill an array with radian values representing the vertices of a regular convex polygon.

Arguments:

size

The number of vertices.

orientation

A value in radians specifying the first vertex. Or, by keyword:

\vertex0.0
\sidepi / size
\pointSynonym for \vertex
\flatSynonym for \side
wrap

Angle wrap, in radians.

Inherited class methods

Undocumented class methods

Array.fillNoteNames(startNote: "C3", endNote: "B3", step: 1)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

Array.makeScale(groundNote: "C3", type: 'major', startNote, endNote)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

Array.makeScaleCps(groundNote: 261.62556530114, type: 'major', startNote, endNote)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

Array.makeScaleMidi(groundNote: 60, type: 'major', startNote, endNote)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

Array.makeScaleName(groundNote: "C3", type: 'major', startNote, endNote)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

Instance Methods

.at(index)

From superclass: ArrayedCollection

Return the item at index.

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

.put(index, item)

From superclass: ArrayedCollection

Put item at index, replacing what is there.

.insert(index, item)

From superclass: ArrayedCollection

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.

.clipAt(index)

From superclass: ArrayedCollection

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

.wrapAt(index)

From superclass: ArrayedCollection

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

.foldAt(index)

From superclass: ArrayedCollection

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

.clipPut(index, item)

From superclass: ArrayedCollection

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

.wrapPut(index, item)

From superclass: ArrayedCollection

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

.foldPut(index, item)

From superclass: ArrayedCollection

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

.swap(i, j)

From superclass: ArrayedCollection

Swap the values at indices i and j.

.replace(find, replace)

From superclass: ArrayedCollection

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 :

++(anArray)

From superclass: ArrayedCollection

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

.add(item)

From superclass: ArrayedCollection

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)

From superclass: ArrayedCollection

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.

.addFirst(item)

From superclass: ArrayedCollection

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

.removeAt(index)

From superclass: ArrayedCollection

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

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

.do(function)

From superclass: ArrayedCollection

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)

From superclass: ArrayedCollection

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

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

From superclass: ArrayedCollection

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

.reshape( ... shape)

From superclass: ArrayedCollection

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.

.windex

From superclass: ArrayedCollection

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

.size

From superclass: ArrayedCollection

Return the number of elements the ArrayedCollection.

.normalize(min: 0.0, max: 1.0)

From superclass: ArrayedCollection

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

.normalizeSum

From superclass: ArrayedCollection

Returns the Array resulting from :

so that the array will sum to 1.0.

This is useful for using with windex or wchoose.

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

From superclass: ArrayedCollection

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

.reverse

Returns a new Array whose elements are reversed. The receiver is unchanged.

.scramble

Returns a new Array whose elements have been scrambled. The receiver is unchanged.

.mirror

Return a new Array which is the receiver made into a palindrome. The receiver is unchanged.

.mirror1

Return a new Array which is the receiver made into a palindrome with the last element removed. This is useful if the list will be repeated cyclically, the first element will not get played twice. The receiver is unchanged. If the receiver is a single-element array, a copy is returned.

.mirror2

Return a new Array which is the receiver concatenated with a reversal of itself. The center element is duplicated. The receiver is unchanged.

.stutter(n: 2)

NOTE: It is recommended to use dupEach instead. This method is retained for backwards compatibility.

Return a new Array whose elements are repeated n times. The receiver is unchanged.

Arguments:

n

Number of repeats.

.dupEach(n: 2)

Return a new Array whose elements are repeated n times. The receiver is unchanged.

Arguments:

n

Number of repeats.

.rotate(n: 1)

Return a new Array whose elements are in rotated order. The receiver is unchanged.

Arguments:

n

Number of elements to rotate. Negative n values rotate left, positive n values rotate right.

.pyramid(patternType: 1)

Return a new Array whose elements have been reordered via one of 10 "counting" algorithms. Run the examples to see the algorithms.

Arguments:

patternType

Choose counting algorithm. The algorithms are numbered 1 through 10.

.pyramidg(patternType: 1)

Like pyramid, but keep the resulting values grouped in subarrays.

.sputter(probability: 0.25, maxlen: 100)

Return a new Array of length maxlen with the items partly repeated (random choice of given probability).

Arguments:

probability

Probability of repeat.

maxlen

The length of the new Array.

.lace(length)

Returns a new Array whose elements are interlaced sequences of the elements of the receiver's subcollections, up to size length. The receiver is unchanged.

.permute(nthPermutation)

Returns a new Array whose elements are the nthPermutation of the elements of the receiver. The receiver is unchanged.

.allTuples(maxTuples: 16384)

Returns a new Array whose elements contain all possible combinations of the receiver's subcollections.

.wrapExtend(length)

Returns a new Array whose elements are repeated sequences of the receiver, up to size length. The receiver is unchanged.

.foldExtend(length)

Same as wrapExtend but the sequences fold back on the list elements.

.clipExtend(length)

Same as wrapExtend but the sequences "clip" (return their last element) rather than wrapping.

.slide(windowLength: 3, stepSize: 1)

Return a new Array whose elements are repeated subsequences from the receiver. Easier to demonstrate than explain.

.shift(n, filler: 0.0)

Shift the values of the array n steps to the right (n positive) or to the left(n negative), dropping the excess and filling empty space with zero.

.containsSeqColl

Returns true if the receiver Array contains any instance of SequenceableCollection

.powerset

Returns all possible combinations of the array's elements.

powerset is also supported in Collection:

.envirPairs

Given an array of symbols, this returns an array of pairs of (symbol, value) from the current environment. This can then be used as arguments for a Synth, or in an OSC message.

.flop

Invert rows and columns in a two dimensional Array (turn inside out). See also: Function, SequenceableCollection.

.multiChannelExpand

Used by UGens to perform multi channel expansion. Same as flop.

.source

Some UGens return Arrays of OutputProxy when instantiated. This method allows you to get at the source UGen.

.fork(join, clock, quant: 0.0, stackSize: 64)

Used within Routines and assumes an array of functions, from which subroutines are created. The subroutines are played while the outer Routine carries on. The join parameter expresses after how many subroutines complete the outer Routine is allowed to go on. By default this happens after all subroutines have completed.

.poll(trig: 10, label, trigid: -1)

apply an array of Poll units to an array of UGens (see those helpfiles for more details).

.dpoll(label, run: 1, trigid: -1)

apply an array of Dpoll units to an array of UGens (see those helpfiles for more details).

.atIdentityHash(argKey)

This method is used by IdentitySet to search for a key among its members.

.atIdentityHashInPairs(argKey)

This method is used by IdentityDictionary to search for a key among its members.

.asString(limit: 512)

From superclass: Object

Returns a string representing the Array. May not be compilable due to elision (...) of excessive arguments.

.asCompileString

From superclass: Object

Returns a string that will compile to return an Array equal to the receiver.

.isValidUGenInput

Returns true. Arrays are valid UGen inputs.

.asRawOSC

Returns the OSC message as an Int8Array. Receiver must be a bundle.

Bela

.belaScope(scopeChannel, server)

From extension in /SuperCollider/Contents/Resources/SCClassLibrary/Common/Audio/Bela/BelaScope.sc

Send this Array's content to Bela's Oscilloscope (see BelaScope for required setup)

Arguments:

scopeChannel

Bela's oscilloscope channel to start scoping on. This has to be a non-negative number, and can't be changed after scoping starts.

server

The server on which BelaScope is running. If not specified, it looks for the first server for which BelaScope was already initialized. If none is found, it attempts to initialize a BelaScope instance on Server: *default.

Returns:

This Array.

Inherited instance methods

Undocumented instance methods

.allSplineIntControls(amt, clipMode: 'wrap')

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.asActionFunc

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/Various/ActionFunc.sc

.asAudioRateInput(for)

.asControlInput

.asNote(cents)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-asNote.sc

.asRewritingRule

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/MathLib/classes/LazyLindenmayer/extStringRewrite.sc

.asSpec

.asUGenInput(for)

.atB(index, loop: true, extra)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.atH(index, loop: true)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.atL(index, loop: true)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.atQ(index, loop: true)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.atS(index, loop: true, extra)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.atSin(index, loop: true)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.bSplineInt(i, amt, loop: true)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.bSplineInt2(i, amt, loop: true)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.bSplineIntControls(amt: 4)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.bSplineIntDeltaControls(amt: 4)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.buildForProxy(proxy, channelOffset: 0)

From extension in /SuperCollider/Contents/Resources/SCClassLibrary/JITLib/ProxySpace/wrapForNodeProxy.sc

.cpsname(sign)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

.deinterlace(clumpSize: 2, numChan: 1)

.eliminateMatrix

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/MathLib/classes/various/matrix_elimination.sc

.envAt(time)

.fastAtL(index)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.fillEnds(nStart: 1, nEnd: 2)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.findReplace(findString, replaceString: "", ignoreCase: false)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/String/extString-findReplace.sc

.ghostAt(i)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.hermiteInt(i)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.intAt(index, type: 'linear', loop: true, extra)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.interlace(clumpSize: 1)

.interpolate(division: 10, type: 'linear', loop: true, extra, close: false)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.linearInt(i, step: 0)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.madd(mul: 1.0, add: 0.0)

.matchForRewriting(string, value, args)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/MathLib/classes/LazyLindenmayer/extStringRewrite.sc

.midiname(sign)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

.modeAt(index, mode: 'wrap')

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.namecps(cents)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

.namemidi(cents)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

.namename(cents, sign)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Note/extVarious-midiname.sc

.numChannels

.prUnarchive(slotArray)

.prUnlace(clumpSize: 2, numChan: 1)

.proxyControlClass

From extension in /SuperCollider/Contents/Resources/SCClassLibrary/JITLib/ProxySpace/wrapForNodeProxy.sc

.quadInt(i)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.quadIntControl

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.quadIntFunction(i, x1)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.resize(newSize: 10, type: 'linear', loop: false, extra)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.rewritingContextFree

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/MathLib/classes/LazyLindenmayer/extStringRewrite.sc

.rewritingRuleSize

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/MathLib/classes/LazyLindenmayer/extStringRewrite.sc

.rotateL(n: 0)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/UGens/extArray-Rotation.sc

.rotateN(n: 0)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/UGens/extArray-Rotation.sc

.rotateS(n: 0)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/UGens/extArray-Rotation.sc

.scope(name: "UGen Scope", bufsize: 4096, zoom: 1.0)

From extension in /SuperCollider/Contents/Resources/SCClassLibrary/Common/GUI/PlusGUI/Control/UGen-scope.sc

.selectFindString(stringToFind, ignoreCase: false)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Extensions/String/extString-findReplace.sc

.sineInt(i)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.splineInt(i, amt)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.splineIntControls(amt)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.splineIntFunction(i, x1, x2)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.splineIntFunctionArray(i, x1array, x2array)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.splineIntPart1(x1, x2)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.splineIntPart2(i)

From extension in /Library/Application Support/SuperCollider/downloaded-quarks/wslib/wslib-classes/Main Features/Interpolation/extArray-interpolation.sc

.unlace(clumpSize: 2, numChan: 1, clip: false)