CollectionBase

CollectionBase class

Provides the abstract base class for a strongly typed collection.

Constructors

NameDescription
CollectionBaseInitializes a new instance of the CollectionBase class with the default initial capacity.
CollectionBaseInitializes a new instance of the CollectionBase class with the specified capacity.

Methods

NameDescription
iteratorReturns an enumerator that iterates through the CollectionBase instance.
getCountGets the number of elements contained in the CollectionBase instance.
clearRemoves all objects from the CollectionBase instance.
addAdds an item to the CollectionBase instance.
getGet an item at specified position.
containsReturn whether instance contains this object
removeAtRemoves the item at the specified index.
indexOfDetermines the index of a specific item in the CollectionBase instance.

CollectionBase() (1 of 2)

Initializes a new instance of the CollectionBase class with the default initial capacity.


CollectionBase(capacity) (2 of 2)

Initializes a new instance of the CollectionBase class with the specified capacity.

ParameterTypeDescription
capacityintThe number of elements that the new list can initially store.

iterator()

Returns an enumerator that iterates through the CollectionBase instance.

Returns: An iterator for the CollectionBase instance.

getCount()

Gets the number of elements contained in the CollectionBase instance.

Returns: The number of elements contained in the CollectionBase instance.

clear()

Removes all objects from the CollectionBase instance.

add(o)

Adds an item to the CollectionBase instance.

ParameterTypeDescription
oObjectThe Object to add to the CollectionBase instance.

Returns: The position into which the new element was inserted.

get(index)

Get an item at specified position.

ParameterTypeDescription
indexintSpecified position index.

Returns: The item at specified position.

contains(o)

Return whether instance contains this object

ParameterTypeDescription
oObjecttest object

Returns: Whether instance contains this object

removeAt(index)

Removes the item at the specified index.

ParameterTypeDescription
indexintThe zero-based index of the item to remove.

indexOf(o)

Determines the index of a specific item in the CollectionBase instance.

ParameterTypeDescription
oObjectDetermines the index of a specific item in the CollectionBase instance.

Returns: The index of value if found in the list; otherwise, -1.