System.Collections.ObjectModel
Class Collection<T>

java.lang.Object
  extended by System.Collections.ObjectModel.Collection<T>
All Implemented Interfaces:
java.lang.Iterable<T>

public class Collection<T>
extends java.lang.Object
implements java.lang.Iterable<T>

Provides the base class for a generic collection.

Author:
Halofreak1990

Constructor Summary
Collection()
          Initializes a new instance of the Collection<> class that is empty.
Collection(java.util.List<T> list)
          Initializes a new instance of the Collection<> class as a wrapper for the specified list.
 
Method Summary
 void Add(T item)
          Adds an object to the end of the Collection<>.
 void Clear()
          Removes all elements from the Collection<>.
protected  void ClearItems()
          Removes all elements from the Collection<>.
 int Count()
          Gets the number of elements actually contained in the Collection<>.
 T get(int index)
          Gets the element at the specified index.
 int IndexOf(T item)
          Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection<>.
 void Insert(int index, T item)
          Inserts an element into the Collection<> at the specified index.
protected  void InsertItem(int index, T item)
          Inserts an element into the Collection<> at the specified index.
 java.util.Iterator<T> iterator()
           
protected  void RemoveItem(int index)
          Removes the element at the specified index of the Collection<>.
 void set(int index, T item)
          Sets the element at the specified index.
protected  void SetItem(int index, T item)
          Replaces the element at the specified index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Collection

public Collection()
Initializes a new instance of the Collection<> class that is empty.


Collection

public Collection(java.util.List<T> list)
Initializes a new instance of the Collection<> class as a wrapper for the specified list.

Parameters:
list - The list that is wrapped by the new collection.
Method Detail

get

public T get(int index)
Gets the element at the specified index.

Parameters:
index - The zero-based index of the element to get.
Returns:
The element at the specified index.

set

public void set(int index,
                T item)
Sets the element at the specified index.

Parameters:
index - The zero-based index of the element to set.
item - The new value for the element at the specified index. The value can be null for reference types.

Add

public void Add(T item)
Adds an object to the end of the Collection<>.

Parameters:
item - The object to be added to the end of the Collection<>. The value can be null for reference types.

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>

Clear

public void Clear()
Removes all elements from the Collection<>.


ClearItems

protected void ClearItems()
Removes all elements from the Collection<>.


Count

public int Count()
Gets the number of elements actually contained in the Collection<>.

Returns:
The number of elements actually contained in the Collection<>.

IndexOf

public int IndexOf(T item)
Searches for the specified object and returns the zero-based index of the first occurrence within the entire Collection<>.

Parameters:
item - The object to locate in the List<>. The value can be null for reference types.
Returns:
The zero-based index of the first occurrence of item within the entire Collection<>, if found; otherwise, -1.

Insert

public void Insert(int index,
                   T item)
Inserts an element into the Collection<> at the specified index.

Parameters:
index - The object to insert. The value can be null for reference types.
item - The zero-based index at which item should be inserted.

InsertItem

protected void InsertItem(int index,
                          T item)
Inserts an element into the Collection<> at the specified index.

Parameters:
index - The object to insert. The value can be null for reference types.
item - The zero-based index at which item should be inserted.

RemoveItem

protected void RemoveItem(int index)
Removes the element at the specified index of the Collection<>.

Parameters:
index - The zero-based index of the element to remove.

SetItem

protected void SetItem(int index,
                       T item)
Replaces the element at the specified index.

Parameters:
index - The zero-based index of the element to replace.
item - The new value for the element at the specified index. The value can be null for reference types.