CollectionBase
CollectionBase class
Provides the abstract base class for a strongly typed collection.
Constructors
| Name | Description |
|---|---|
| CollectionBase | Initializes a new instance of the CollectionBase class with the default initial capacity. |
| CollectionBase | Initializes a new instance of the CollectionBase class with the specified capacity. |
Methods
| Name | Description |
|---|---|
| iterator | Returns an enumerator that iterates through the CollectionBase instance. |
| getCount | Gets the number of elements contained in the CollectionBase instance. |
| clear | Removes all objects from the CollectionBase instance. |
| add | Adds an item to the CollectionBase instance. |
| get | Get an item at specified position. |
| contains | Return whether instance contains this object |
| removeAt | Removes the item at the specified index. |
| indexOf | Determines 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.
| Parameter | Type | Description |
|---|---|---|
| capacity | int | The 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.
| Parameter | Type | Description |
|---|---|---|
| o | Object | The 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.
| Parameter | Type | Description |
|---|---|---|
| index | int | Specified position index. |
Returns: The item at specified position.
contains(o)
Return whether instance contains this object
| Parameter | Type | Description |
|---|---|---|
| o | Object | test object |
Returns: Whether instance contains this object
removeAt(index)
Removes the item at the specified index.
| Parameter | Type | Description |
|---|---|---|
| index | int | The zero-based index of the item to remove. |
indexOf(o)
Determines the index of a specific item in the CollectionBase instance.
| Parameter | Type | Description |
|---|---|---|
| o | Object | Determines the index of a specific item in the CollectionBase instance. |
Returns: The index of value if found in the list; otherwise, -1.