Foley.Utilities.Collections
Class List2Base

Provides an abstract implementation of the Foley.Utilities.Collections.IList2 interface and extends Foley.Utilities.Collections.Collection2Base.

The main purpose of this is an all purpose base class that can be extended by any class that wants to be a list.

Constructor Summary
List2Base()
         Protected constructor for abstract class.

Property Summary
object Item[int index]
         Gets or sets the System.Object at the specified index. In C#, this property is the indexer for the list.

Properties inherited from class Foley.Utilities.Collections.Collection2Base
Count, IsEmpty, IsFixedSize, IsReadOnly, IsSynchronized, SyncRoot

Method Summary
int Add(object value)
         When implemented by a class, adds an System.Object to the list.
bool Add(System.Collections.ICollection collection)
         Adds the elements of the specified System.Collections.ICollection to the list.
bool Contains(object value)
         Determines whether the specified System.Object is in the list.
bool Contains(System.Collections.ICollection collection)
         Determines whether all the elements in the specified System.Collections.ICollection are contained in the list.
System.Collections.IEnumerator GetEnumerator(int index)
         When implemented by a class, returns an System.Collections.IEnumerator that can iterate through the list that starts at the specified position.
void IList.Insert(int index, object value)
         This method provided for backwards compatiblity with IList.
void IList.Remove(object value)
         This method provided for backwards compatiblity with System.Collections.IList.
void IList.RemoveAt(int index)
         This method provided for backwards compatiblity with System.Collections.IList.
int IndexOf(object value)
         When implemented by a class, searches for the specified System.Object and returns the zero-based index of the first occurrence within the list.
bool Insert(int index, System.Collections.ICollection collection)
         When implemented by a class, inserts the elements of the System.Collections.ICollection to the list starting at the specified position.
bool Insert(int index, object value)
         When implemented by a class, inserts the System.Object specified into the list at the specified position.
int LastIndexOf(object value)
         When implemented by a class, determines the index of the last occurrence of the specified System.Object in the list.
bool Remove(System.Collections.ICollection collection)
         Removes the first occurrence of each element of the specified System.Collections.ICollection from the list.
bool Remove(int index, int count)
         When implemented by a class, removes the specified number of the elements starting at the position specified.
bool Remove(object value)
         When implemented by a class, removes the first occurrence of a specific System.Object from the list.
bool RemoveAt(int index)
         When implemented by a class, removes the element at the specified position from the list.
bool Retain(System.Collections.ICollection collection)
         Retains the first occurrence of each element of the specified System.Collections.ICollection from the list.
System.Collections.IList SubList(int index, int count)
         When implemented by a class, provides a view of the list with the specified number of the elements starting at the position specified.

Methods inherited from class Foley.Utilities.Collections.Collection2Base
Clear, CopyTo, GetEnumerator, IsContainedIn

Methods inherited from class System.Object
Equals, Finalize, GetHashCode, GetType, MemberwiseClone, ToString


Constructor Detail

List2Base

protected List2Base()

Protected constructor for abstract class.

Property Detail

Item

public object this[int index]

Gets or sets the System.Object at the specified index. In C#, this property is the indexer for the list.

Parameters:
index - The zero-based index of the element to get or set.
Value:
The element at the specified index.
Method Detail

Add

public int Add(object value)

When implemented by a class, adds an System.Object to the list.

Parameters:
value - The System.Object to be added to the end of the list.
Returns:
The zero-based index at which the System.Object was added.

Add

public bool Add(System.Collections.ICollection collection)

Adds the elements of the specified System.Collections.ICollection to the list.

Parameters:
collection - The System.Collections.ICollection whose elements are added to the list.
Returns:
true if the list is modified; otherwise false.
Throws:
System.NullReferenceException - The collection is a null reference (Nothing in Visual Basic).

Contains

public bool Contains(object value)

Determines whether the specified System.Object is in the list.

This method determines equality by calling System.Object.Equals(System.Object). Keep in mind that the System.Object to locate can be a null reference (Nothing in Visual Basic). If you do not want this behaviour you must override this method.

Parameters:
value - The System.Object to check if it is contained in the list.
Returns:
true if the System.Object is found in the list; otherwise, false.

Contains

public bool Contains(System.Collections.ICollection collection)

Determines whether all the elements in the specified System.Collections.ICollection are contained in the list.

This method determines equality by calling System.Object.Equals(System.Object). Keep in mind that the System.Object to locate can be a null reference (Nothing in Visual Basic). If you do not want this behaviour you must override this method.

Parameters:
collection - The System.Collections.ICollection whose elements are to be checked if all of its elements are contained in the list.
Returns:
true if all the elements of the System.Collections.ICollection are found in the list; otherwise, false.
Throws:
System.NullReferenceException - The collection is a null reference (Nothing in Visual Basic).

GetEnumerator

public System.Collections.IEnumerator GetEnumerator(int index)

When implemented by a class, returns an System.Collections.IEnumerator that can iterate through the list that starts at the specified position.

Parameters:
index - Starting index in the list for the begining of the System.Collections.IEnumerator.
Returns:
An System.Collections.IEnumerator that can be used to iterate through the list.

IList.Insert

private void IList.Insert(int index,
                          object value)

This method provided for backwards compatiblity with IList.


IList.Remove

private void IList.Remove(object value)

This method provided for backwards compatiblity with System.Collections.IList.


IList.RemoveAt

private void IList.RemoveAt(int index)

This method provided for backwards compatiblity with System.Collections.IList.


IndexOf

public int IndexOf(object value)

When implemented by a class, searches for the specified System.Object and returns the zero-based index of the first occurrence within the list.

Parameters:
value - The System.Object to locate in the list.
Returns:
The zero-based index of the first occurrence of System.Object within the list, if found; otherwise, -1.

Insert

public bool Insert(int index,
                   System.Collections.ICollection collection)

When implemented by a class, inserts the elements of the System.Collections.ICollection to the list starting at the specified position.

Parameters:
index - The zero-based index at which collection should be inserted.
collection - The System.Collections.ICollection whose elements are to be added to the list.
Returns:
true if the list is modified; otherwise false.
Throws:
System.NotSupportedException -

The list is read-only.

-or-

The list has a fixed size.


Insert

public bool Insert(int index,
                   object value)

When implemented by a class, inserts the System.Object specified into the list at the specified position.

This method hides the System.Collections.IList.Insert(System.Int32,System.Object) method. It is recommened that you do an explicit interface method implementation for complete compatibility.

Parameters:
index - The zero-based index at which the System.Object should be inserted.
value - The System.Object to insert into the list.
Returns:
true if the list is modified; otherwise false.
Throws:
System.NotSupportedException -

The list is read-only.

-or-

The list has a fixed size.


LastIndexOf

public int LastIndexOf(object value)

When implemented by a class, determines the index of the last occurrence of the specified System.Object in the list.

Parameters:
value - The System.Object to locate in the list.
Returns:
The zero-based index of the last occurrence of the value in the list, if found; otherwise, -1.

Remove

public bool Remove(System.Collections.ICollection collection)

Removes the first occurrence of each element of the specified System.Collections.ICollection from the list.

Parameters:
collection - The System.Collections.ICollection used to determine what elements to remove from the list.
Returns:
true if the list is modified; otherwise false.
Throws:
System.NotSupportedException -

The list is read-only.

-or-

The list has a fixed size.


Remove

public bool Remove(int index,
                   int count)

When implemented by a class, removes the specified number of the elements starting at the position specified.

Parameters:
index - Starting index for removing elements from the list.
count - The number of elements to remove from the list.
Returns:
true if the list is modified; otherwise false.
Throws:
System.NotSupportedException -

The list is read-only.

-or-

The list has a fixed size.


Remove

public bool Remove(object value)

When implemented by a class, removes the first occurrence of a specific System.Object from the list.

Parameters:
value - The System.Object to remove from the list.
Returns:
true if the list is modified; otherwise false.

RemoveAt

public bool RemoveAt(int index)

When implemented by a class, removes the element at the specified position from the list.

Parameters:
index - The index of the element to remove from the list.
Returns:
true if the list is modified; otherwise false.
Throws:
System.NotSupportedException -

The list is read-only.

-or-

The list has a fixed size.


Retain

public bool Retain(System.Collections.ICollection collection)

Retains the first occurrence of each element of the specified System.Collections.ICollection from the list.

Parameters:
collection - The System.Collections.ICollection used to determine what elements to be retained in the list.
Returns:
true if the list is modified; otherwise false.
Throws:
System.NotSupportedException -

The list is read-only.

-or-

The list has a fixed size.


SubList

public System.Collections.IList SubList(int index,
                                        int count)

When implemented by a class, provides a view of the list with the specified number of the elements starting at the position specified.

The list that is returned is just a view, it is still backed by the orignal list. Any changes you make to it will be reflected in the orignal list.

Parameters:
index - Starting index for the view of elements from the list.
count - The number of elements to include in the view of the list.
Returns:
A view of list.