Class Collection

Represents a collection of objects.

ArrayList, FilteringCollection, HashSet, LinkedHashSet, List, Set, SortedSet

PropertyDescription
empty: Boolean (read-only)Returns true if the collection is empty.
length: Number (read-only)Returns the length of the collection.

This class does not have a constructor, so you cannot create it directly.

MethodDescription
add(Object...)Adds the specified objects to the collection.
add1(Object)The method adds a single object to the collection.
addAll(Collection)Adds the collection of objects to the collection.
clear()Clears the collection.
contains(Object)Returns true if the collection contains the specified object.
containsAll(Collection)Returns true if the collection contains all of the objects in the specified collection.
getLength()Returns the length of the collection.
isEmpty()Returns true if the collection is empty.
iterator()Returns an iterator that can be used to access the members of the collection.
remove(Object)Removes the specified object from the collection.
removeAll(Collection)Removes all of object in the specified object from the collection.
retainAll(Collection)Removes all of object in the collection that are not in the specified collection.
size()Returns the size of the collection.
toArray()Returns all elements of this collection in a newly created array.
toArray(Number, Number)Returns a subset of the elements of this collection in a newly created array.

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

empty: Boolean (read-only)

Returns true if the collection is empty.


length: Number (read-only)

Returns the length of the collection. This is similar to to a ECMA array of 'products.length'.


add(values: Object...): Boolean

Adds the specified objects to the collection. The method can also be called with an ECMA array as argument.

If called with a single ECMA array as argument the individual elements of that array are added to the collection. If the array object itself should be added use the method add1().

Parameters:

  • values - the values to add.

Returns:

  • true if the values were added, false otherwise.

add1(object: Object): Boolean

The method adds a single object to the collection.

Parameters:

  • object - the object to add.

Returns:

  • true if the object was added, false otherwise.

addAll(objs: Collection): Boolean

Adds the collection of objects to the collection.

Parameters:

  • objs - the objects to add.

Returns:

  • true if the objects were added, false otherwise.

clear(): void

Clears the collection.


contains(obj: Object): Boolean

Returns true if the collection contains the specified object.

Parameters:

  • obj - the object to locate in this collection.

Returns:

  • true if the collection contains the specified object, false otherwise.

containsAll(objs: Collection): Boolean

Returns true if the collection contains all of the objects in the specified collection.

Parameters:

  • objs - the collection of objects to locate in this collection.

Returns:

  • true if the collection contains all of the specified objects, false otherwise.

getLength(): Number

Returns the length of the collection. This is similar to to a ECMA array of 'products.length'.

Returns:

  • the length of the collection.

isEmpty(): Boolean

Returns true if the collection is empty.

Returns:

  • true if the collection is empty, false otherwise

iterator(): Iterator

Returns an iterator that can be used to access the members of the collection.

Returns:

  • an iterator that can be used to access the members of the collection.

remove(obj: Object): Boolean

Removes the specified object from the collection.

Parameters:

  • obj - the object to remove.

Returns:

  • true if the specified object was removed, false otherwise.

removeAll(objs: Collection): Boolean

Removes all of object in the specified object from the collection.

Parameters:

  • objs - the collection of objects to remove.

Returns:

  • true if the all of the specified objects were removed, false otherwise.

retainAll(objs: Collection): Boolean

Removes all of object in the collection that are not in the specified collection.

Parameters:

  • objs - the collection of objects to retain in the collection.

Returns:

  • true if the collection retains all of the specified objects, false otherwise.

size(): Number

Returns the size of the collection.

Returns:

  • the size of the collection.

toArray(): Array

Returns all elements of this collection in a newly created array. The returned array is independent of this collection and can be modified without changing the collection. The elements in the array are in the same order as they are returned when iterating over this collection.

Returns:

  • a newly created array.

toArray(start: Number, size: Number): Array

Returns a subset of the elements of this collection in a newly created array. The returned array is independent of this collection and can be modified without changing the collection. The elements in the array are in the same order as they are returned when iterating over this collection.

Parameters:

  • start - the number of elements to iterate before adding elements to the array. Negative values are treated as 0.
  • size - the maximum number of elements to add to the array. Nonpositive values always result in empty array.

Returns:

  • a newly created array.