Collection (of Object)

class Collection

Defined in System.sc.

The Collection class is used to handle a collection of elements, such as objects.

Subclasses: List.

Properties

Inherited from Object:

Property Description
name  

Defined in Collection:

Property Description
elements  
size  

Methods

doit([...])

Calls the doit method on each element, forwarding any parameters given.

dispose()
showStr(buffer)

Fills buffer with a text stating the object name and collection size.

showSelf()

For the object and each of its elements, this prints the object’s name and collection size on the screen in a dialog box.

add([node ...])

Adds the given nodes to the collection of elements. It returns a pointer to itself. If no nodes are supplied, it is simply ensured that the list is initialized.

Parameters:node – An object to add to the collection.
Returns:Itself.
delete([node ...])

Deletes the specified nodes from the collection of elements. It returns a pointer to the object.

Parameters:node – An object to delete from the collection.
Returns:Itself.
eachElementDo(aSelector [...])

For each element, this calls aSelector (a method or property), forwarding any other given parameters to it.

Parameters:aSelector (selector) – A selector (e.g. #doit, or #moveSpeed).

Example usage:

(myPolyList eachElementDo: #perform drawPoly)
firstTrue(aSelector [...])

For each element, this calls aSelector (a method or property), and if given, the rest of the parameters. The first send to an element to return TRUE will cause firstTrue to return a pointer to that object. If no send returns TRUE, firstTrue will return NULL.

Parameters:aSelector (selector) – A selector (e.g. #doit, or #moveSpeed).
Returns:The first object that returned TRUE, or NULL if no objects returned TRUE.
allTrue(aSelector [...])

For each element, this calls aSelector (a method or property), and if given, the rest of the parameters. If any send to an element returns FALSE, allTrue will return FALSE as well. Otherwise, if all sends have returned TRUE, so will allTrue.

Parameters:aSelector (selector) – A selector (e.g. #doit, or #moveSpeed).
Returns:TRUE if all objects returned TRUE, otherwise FALSE.
contains(node)
Returns:TRUE if the object contains node in its collection of elements.
isEmpty()
Returns:TRUE if the collection contains no nodes (elements). Otherwise, it returns FALSE.
first()
Returns:a pointer to the first node in the collection.
next(node)
Returns:a pointer to the node after the specified one.
release()

Deletes all the nodes (elements) from the collection.

isDuplicate()