Collection is an abstract class. You do not create direct instances of Collection. There are many types of Collections including List, Array, Dictionary, Bag, Set, SortedList, etc. See Collections for a complete class tree.
Creates a new Collection from another collection. This supports the interface for the method "as".
Creates a new Collection from the args.
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.
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". |
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
Creates a 3 dimensional Collection of the given sizes. The items are determined by evaluation of the supplied function. The function is passed plane, row and column indexes as arguments. See J concepts in SC
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
Answers the number of objects contained in the Collection.
Answer whether the receiver contains no objects.
Add anObject to the receiver.
Add all items in aCollection to the receiver.
Remove anObject from the receiver. Answers the removed object.
Remove all items in aCollection from the receiver.
See -removeEvery for a related method that removes all occurrences.
Remove all occurrences of the items in aCollection from the receiver.
Remove all items in the receiver for which function answers True. The function is passed two arguments, the item and an integer index. Answers the objects which have been removed.
Put the values in the corresponding indices given by keys. If one of the two argument arrays is longer then it will wrap.
Return a collection of all the items for the keys.
Answer whether anObject is contained in the receiver.
Answer whether anObject is contained in the receiver. In contrast to -includes this tests for equality - not identity.
Answer whether any item in aCollection is contained in the receiver.
Answer whether all items in aCollection are contained in the receiver.
Evaluates function for each item in the collection. The function is passed two arguments, the item and an integer 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.
If you want to control what type of collection is returned, use -collectAs(function, class).
Answer a new collection which consists of all items in the receiver for which function answers True. The function is passed two arguments, the item and an integer index.
If you want to control what type of collection is returned, use -selectAs(function, class).
Answer a new collection which consists of all items in the receiver for which function answers False. The function is passed two arguments, the item and an integer index.
If you want to control what type of collection is returned, use -rejectAs(function, class).
Answer the first item in the receiver for which function answers True. The function is passed two arguments, the item and an integer index.
Similar to -detect but returns the index instead of the item itself.
In functional programming, the operation known as a left fold. inject takes an initial value and a function and combines the elements of the collection by applying the function to the accumulated value and an element from the collection starting from the first element in the collection. The function takes two arguments and returns the new value. The accumulated value is initialized to initialValue.
In functional programming, the operation known as a right fold. inject takes an initial value and a function and combines the elements of the collection by applying the function to the accumulated value and an element from the collection starting from the last element in the collection. The function takes two arguments and returns the new value. The accumulated value is initialized to initialValue.
Iterate over the collection and replace each item with a new one, returned by the function. This can be useful when one wants to aviod creating a new array in memory. In most cases, it is better to use -collect.
Like -collect, but the collection is copied before iteration. This is recommended wherever the function may change the collection itself.
Answer whether function answers True for any item in the receiver. The function is passed two arguments, the item and an integer index.
Answer whether function answers True for every item in the receiver. The function is passed two arguments, the item and an integer index.
Answer the number of items for which function answers True. The function is passed two arguments, the item and an integer index.
Answer the number of items in the receiver which are equal to anObject.
Answer the sum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index.
Answer the maximum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index. If function is nil, then answer the maximum of all items in the receiver.
Answer the minimum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index. If function is nil, then answer the minimum of all items in the receiver.
Answer the index of the maximum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index. If function is nil, then answer the maximum of all items in the receiver.
Answer the index of the minimum of the results of function evaluated for each item in the receiver. The function is passed two arguments, the item and an integer index. If function is nil, then answer the minimum of all items in the receiver.
Returns the maximum size of all subcollections at a certain depth (dimension)
rank |
The depth at which the size of the collection is measured |
Returns the maximum depth of all subcollections.
max |
Internally used only. |
Returns a Routine that returns the elements one by one.
Answer a Bag to which all items in the receiver have been added.
Answer a List to which all items in the receiver have been added.
Answer a Set to which all items in the receiver have been added.
Answer a SortedList to which all items in the receiver have been added.
Answer a corresponding dictionary. This is part of the Key Value Pairs interface.
mergeFunc |
Use this function to decide what to do with duplicate keys. |
class |
The class of the dictionary to be returned. By default this is an IdentityDictionary. |
Answer an array of Associations. If the first item of the list is already an associiation, return itself. This is part of the Key Value Pairs interface.
class |
The class of the collection to be returned. By default this is an Array. |
Answer an array with alternating key value pairs, like [\freq, 1848, \amp, 0.2]
. This is part of the Key Value Pairs interface.
class |
The class of the collection to be returned. By default this is an Array. |
Answer an Event: with the key value pairs. See Key Value Pairs.
used internally by asDict
.
Returns all possible combinations of the collection's elements.
Takes a collection of dictionaries and returns a single dictionary with arrays of all dictionaries' elements. If unbubble is True (default), and if one element is singular, the array is replaced by this element.
Returns a histogram of the collection by counting the number of values that fall into each slot of size (default: 100) subdivisions between min and max. If there are any values outside this range, it posts a note. If min or max is not given, the smallest (or largest value respectively) is used.
Subtractively invert a collection about a value (default: sum of minimal and maximum value). It can be used to invert a pitch list about a given axis.
Print a representation of the collection to a stream.
Write a compilable representation of the collection to a stream.
Print a comma separated compilable representation of the items in the collection to a stream.
Write a comma separated compilable representation of the items in the collection to a stream.
Return the set theoretical intersection of this and that.
Return the set theoretical union of this and that.
Return the set of all items which are elements of this, but not of that.
Return the set of all items which are not elements of both this and that. this -- that
Returns True if all elements of this are also elements of that