NetTopologySuite
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Pages
Wintellect.PowerCollections.ListBase< T > Class Template Referenceabstract

ListBase is an abstract class that can be used as a base class for a read-write collection that needs to implement the generic IList<T> and non-generic IList collections. The derived class needs to override the following methods: Count, Clear, Insert, RemoveAt, and the indexer. The implementation of all the other methods in IList<T> and IList are handled by ListBase. More...

Inheritance diagram for Wintellect.PowerCollections.ListBase< T >:
Wintellect.PowerCollections.CollectionBase< T > Wintellect.PowerCollections.BigList< T > Wintellect.PowerCollections.Deque< T >

Public Member Functions

abstract override void Clear ()
 This method must be overridden by the derived class to empty the list of all items. More...
 
abstract void Insert (int index, T item)
 This method must be overridden by the derived class to insert a new item at the given index. More...
 
abstract void RemoveAt (int index)
 This method must be overridden by the derived class to remove the item at the given index. More...
 
override IEnumerator< T > GetEnumerator ()
 Enumerates all of the items in the list, in order. The item at index 0 is enumerated first, then the item at index 1, and so on. More...
 
override bool Contains (T item)
 Determines if the list contains any item that compares equal to item . The implementation simply checks whether IndexOf(item) returns a non-negative value. More...
 
override void Add (T item)
 Adds an item to the end of the list. This method is equivalent to calling: More...
 
override bool Remove (T item)
 Searches the list for the first item that compares equal to item . If one is found, it is removed. Otherwise, the list is unchanged. More...
 
virtual void CopyTo (T[] array)
 Copies all the items in the list, in order, to array , starting at index 0. More...
 
override void CopyTo (T[] array, int arrayIndex)
 Copies all the items in the list, in order, to array , starting at arrayIndex . More...
 
virtual void CopyTo (int index, T[] array, int arrayIndex, int count)
 Copies a range of elements from the list to array , starting at arrayIndex . More...
 
virtual new IList< T > AsReadOnly ()
 Provides a read-only view of this list. The returned IList<T> provides a view of the list that prevents modifications to the list. Use the method to provide access to the list without allowing changes. Since the returned object is just a view, changes to the list will be reflected in the view. More...
 
virtual T Find (Predicate< T > predicate)
 Finds the first item in the list that satisfies the condition defined by predicate . If no item matches the condition, than the default value for T (null or all-zero) is returned. More...
 
virtual bool TryFind (Predicate< T > predicate, out T foundItem)
 Finds the first item in the list that satisfies the condition defined by predicate . More...
 
virtual T FindLast (Predicate< T > predicate)
 Finds the last item in the list that satisfies the condition defined by predicate . If no item matches the condition, than the default value for T (null or all-zero) is returned. More...
 
virtual bool TryFindLast (Predicate< T > predicate, out T foundItem)
 Finds the last item in the list that satisfies the condition defined by predicate . More...
 
virtual int FindIndex (Predicate< T > predicate)
 Finds the index of the first item in the list that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned. More...
 
virtual int FindIndex (int index, Predicate< T > predicate)
 Finds the index of the first item, in the range of items extending from index to the end, that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned. More...
 
virtual int FindIndex (int index, int count, Predicate< T > predicate)
 Finds the index of the first item, in the range of count items starting from index , that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned. More...
 
virtual int FindLastIndex (Predicate< T > predicate)
 Finds the index of the last item in the list that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned. More...
 
virtual int FindLastIndex (int index, Predicate< T > predicate)
 Finds the index of the last item, in the range of items extending from the beginning of the list to index , that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned. More...
 
virtual int FindLastIndex (int index, int count, Predicate< T > predicate)
 Finds the index of the last item, in the range of count items ending at index , that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned. More...
 
virtual int IndexOf (T item)
 Finds the index of the first item in the list that is equal to item . More...
 
virtual int IndexOf (T item, int index)
 Finds the index of the first item, in the range of items extending from index to the end, that is equal to item . More...
 
virtual int IndexOf (T item, int index, int count)
 Finds the index of the first item, in the range of count items starting from index , that is equal to item . More...
 
virtual int LastIndexOf (T item)
 Finds the index of the last item in the list that is equal to item . More...
 
virtual int LastIndexOf (T item, int index)
 Finds the index of the last item, in the range of items extending from the beginning of the list to index , that is equal to item . More...
 
virtual int LastIndexOf (T item, int index, int count)
 Finds the index of the last item, in the range of count items ending at index , that is equal to item . More...
 
virtual IList< T > Range (int start, int count)
 Returns a view onto a sub-range of this list. Items are not copied; the returned IList<T> is simply a different view onto the same underlying items. Changes to this list are reflected in the view, and vice versa. Insertions and deletions in the view change the size of the view, but insertions and deletions in the underlying list do not. More...
 
- Public Member Functions inherited from Wintellect.PowerCollections.CollectionBase< T >
override string ToString ()
 Shows the string representation of the collection. The string representation contains a list of the items in the collection. Contained collections (except string) are expanded recursively. More...
 

Protected Member Functions

 ListBase ()
 Creates a new ListBase. More...
 
- Protected Member Functions inherited from Wintellect.PowerCollections.CollectionBase< T >
 CollectionBase ()
 Creates a new CollectionBase. More...
 

Properties

abstract override int Count [get]
 The property must be overridden by the derived class to return the number of items in the list. More...
 
abstract T this[int index] [get, set]
 The indexer must be overridden by the derived class to get and set values of the list at a particular index. More...
 

Detailed Description

ListBase is an abstract class that can be used as a base class for a read-write collection that needs to implement the generic IList<T> and non-generic IList collections. The derived class needs to override the following methods: Count, Clear, Insert, RemoveAt, and the indexer. The implementation of all the other methods in IList<T> and IList are handled by ListBase.

Template Parameters
T

Constructor & Destructor Documentation

Wintellect.PowerCollections.ListBase< T >.ListBase ( )
protected

Creates a new ListBase.

Member Function Documentation

override void Wintellect.PowerCollections.ListBase< T >.Add ( item)

Adds an item to the end of the list. This method is equivalent to calling:

Insert(Count, item)

Parameters
itemThe item to add to the list.
virtual new IList<T> Wintellect.PowerCollections.ListBase< T >.AsReadOnly ( )
virtual

Provides a read-only view of this list. The returned IList<T> provides a view of the list that prevents modifications to the list. Use the method to provide access to the list without allowing changes. Since the returned object is just a view, changes to the list will be reflected in the view.

Returns
An IList<T> that provides read-only access to the list.
abstract override void Wintellect.PowerCollections.ListBase< T >.Clear ( )
pure virtual

This method must be overridden by the derived class to empty the list of all items.

Implemented in Wintellect.PowerCollections.BigList< T >, and Wintellect.PowerCollections.Deque< T >.

override bool Wintellect.PowerCollections.ListBase< T >.Contains ( item)

Determines if the list contains any item that compares equal to item . The implementation simply checks whether IndexOf(item) returns a non-negative value.

Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality.

Parameters
itemThe item to search for.
Returns
True if the list contains an item that compares equal to item .
virtual void Wintellect.PowerCollections.ListBase< T >.CopyTo ( T[]  array)
virtual

Copies all the items in the list, in order, to array , starting at index 0.

Parameters
arrayThe array to copy to. This array must have a size that is greater than or equal to Count.
override void Wintellect.PowerCollections.ListBase< T >.CopyTo ( T[]  array,
int  arrayIndex 
)

Copies all the items in the list, in order, to array , starting at arrayIndex .

Parameters
arrayThe array to copy to. This array must have a size that is greater than or equal to Count + arrayIndex.
arrayIndexThe starting index in array to copy to.
virtual void Wintellect.PowerCollections.ListBase< T >.CopyTo ( int  index,
T[]  array,
int  arrayIndex,
int  count 
)
virtual

Copies a range of elements from the list to array , starting at arrayIndex .

Parameters
indexThe starting index in the source list of the range to copy.
arrayThe array to copy to. This array must have a size that is greater than or equal to Count + arrayIndex.
arrayIndexThe starting index in array to copy to.
countThe number of items to copy.
virtual T Wintellect.PowerCollections.ListBase< T >.Find ( Predicate< T >  predicate)
virtual

Finds the first item in the list that satisfies the condition defined by predicate . If no item matches the condition, than the default value for T (null or all-zero) is returned.

If the default value for T (null or all-zero) matches the condition defined by predicate , and the list might contain the default value, then it is impossible to distinguish the different between finding the default value and not finding any item. To distinguish these cases, use TryFind.

Parameters
predicateA delegate that defined the condition to check for.
Returns
The first item that satisfies the condition predicate . If no item satisfies that condition, the default value for T is returned.
See also
TryFind
virtual int Wintellect.PowerCollections.ListBase< T >.FindIndex ( Predicate< T >  predicate)
virtual

Finds the index of the first item in the list that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned.

Parameters
predicateA delegate that defined the condition to check for.
Returns
The index of the first item that satisfies the condition predicate . If no item satisfies that condition, -1 is returned.
virtual int Wintellect.PowerCollections.ListBase< T >.FindIndex ( int  index,
Predicate< T >  predicate 
)
virtual

Finds the index of the first item, in the range of items extending from index to the end, that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned.

Parameters
predicateA delegate that defined the condition to check for.
indexThe starting index of the range to check.
Returns
The index of the first item in the given range that satisfies the condition predicate . If no item satisfies that condition, -1 is returned.
virtual int Wintellect.PowerCollections.ListBase< T >.FindIndex ( int  index,
int  count,
Predicate< T >  predicate 
)
virtual

Finds the index of the first item, in the range of count items starting from index , that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned.

Parameters
predicateA delegate that defined the condition to check for.
indexThe starting index of the range to check.
countThe number of items in range to check.
Returns
The index of the first item in the given range that satisfies the condition predicate . If no item satisfies that condition, -1 is returned.
virtual T Wintellect.PowerCollections.ListBase< T >.FindLast ( Predicate< T >  predicate)
virtual

Finds the last item in the list that satisfies the condition defined by predicate . If no item matches the condition, than the default value for T (null or all-zero) is returned.

If the default value for T (null or all-zero) matches the condition defined by predicate , and the list might contain the default value, then it is impossible to distinguish the different between finding the default value and not finding any item. To distinguish these cases, use TryFindLast.

Parameters
predicateA delegate that defined the condition to check for.
Returns
The last item that satisfies the condition predicate . If no item satisfies that condition, the default value for T is returned.
See also
TryFindLast
virtual int Wintellect.PowerCollections.ListBase< T >.FindLastIndex ( Predicate< T >  predicate)
virtual

Finds the index of the last item in the list that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned.

Parameters
predicateA delegate that defined the condition to check for.
Returns
The index of the last item that satisfies the condition predicate . If no item satisfies that condition, -1 is returned.
virtual int Wintellect.PowerCollections.ListBase< T >.FindLastIndex ( int  index,
Predicate< T >  predicate 
)
virtual

Finds the index of the last item, in the range of items extending from the beginning of the list to index , that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned.

Parameters
predicateA delegate that defined the condition to check for.
indexThe ending index of the range to check.
Returns
The index of the last item in the given range that satisfies the condition predicate . If no item satisfies that condition, -1 is returned.
virtual int Wintellect.PowerCollections.ListBase< T >.FindLastIndex ( int  index,
int  count,
Predicate< T >  predicate 
)
virtual

Finds the index of the last item, in the range of count items ending at index , that satisfies the condition defined by predicate . If no item matches the condition, -1 is returned.

Parameters
predicateA delegate that defined the condition to check for.
indexThe ending index of the range to check.
countThe number of items in range to check.
Returns
The index of the last item in the given range that satisfies the condition predicate . If no item satisfies that condition, -1 is returned.
override IEnumerator<T> Wintellect.PowerCollections.ListBase< T >.GetEnumerator ( )

Enumerates all of the items in the list, in order. The item at index 0 is enumerated first, then the item at index 1, and so on.

The enumerator does not check for changes made to the structure of the list. Thus, changes to the list during enumeration may cause incorrect enumeration or out of range exceptions. Consider overriding this method and adding checks for structural changes.

Returns
An IEnumerator<T> that enumerates all the items in the list.
virtual int Wintellect.PowerCollections.ListBase< T >.IndexOf ( item)
virtual

Finds the index of the first item in the list that is equal to item .

The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.

Parameters
itemThe item to search fror.
Returns
The index of the first item in the list that that is equal to item . If no item is equal to item , -1 is returned.
virtual int Wintellect.PowerCollections.ListBase< T >.IndexOf ( item,
int  index 
)
virtual

Finds the index of the first item, in the range of items extending from index to the end, that is equal to item .

The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.

Parameters
itemThe item to search fror.
indexThe starting index of the range to check.
Returns
The index of the first item in the given range that that is equal to item . If no item is equal to item , -1 is returned.
virtual int Wintellect.PowerCollections.ListBase< T >.IndexOf ( item,
int  index,
int  count 
)
virtual

Finds the index of the first item, in the range of count items starting from index , that is equal to item .

The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.

Parameters
itemThe item to search fror.
indexThe starting index of the range to check.
countThe number of items in range to check.
Returns
The index of the first item in the given range that that is equal to item . If no item is equal to item , -1 is returned.
abstract void Wintellect.PowerCollections.ListBase< T >.Insert ( int  index,
item 
)
pure virtual

This method must be overridden by the derived class to insert a new item at the given index.

Parameters
indexThe index in the list to insert the item at. After the insertion, the inserted item is located at this index. The first item in the list has index 0.
itemThe item to insert at the given index.
Exceptions
ArgumentOutOfRangeExceptionindex is less than zero or greater than Count.

Implemented in Wintellect.PowerCollections.Deque< T >, and Wintellect.PowerCollections.BigList< T >.

virtual int Wintellect.PowerCollections.ListBase< T >.LastIndexOf ( item)
virtual

Finds the index of the last item in the list that is equal to item .

The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.

Parameters
itemThe item to search fror.
Returns
The index of the last item in the list that that is equal to item . If no item is equal to item , -1 is returned.
virtual int Wintellect.PowerCollections.ListBase< T >.LastIndexOf ( item,
int  index 
)
virtual

Finds the index of the last item, in the range of items extending from the beginning of the list to index , that is equal to item .

The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.

Parameters
itemThe item to search fror.
indexThe ending index of the range to check.
Returns
The index of the last item in the given range that that is equal to item . If no item is equal to item , -1 is returned.
virtual int Wintellect.PowerCollections.ListBase< T >.LastIndexOf ( item,
int  index,
int  count 
)
virtual

Finds the index of the last item, in the range of count items ending at index , that is equal to item .

The default implementation of equality for type T is used in the search. This is the equality defined by IComparable<T> or object.Equals.

Parameters
itemThe item to search for.
indexThe ending index of the range to check.
countThe number of items in range to check.
Returns
The index of the last item in the given range that that is equal to item . If no item is equal to item , -1 is returned.
virtual IList<T> Wintellect.PowerCollections.ListBase< T >.Range ( int  start,
int  count 
)
virtual

Returns a view onto a sub-range of this list. Items are not copied; the returned IList<T> is simply a different view onto the same underlying items. Changes to this list are reflected in the view, and vice versa. Insertions and deletions in the view change the size of the view, but insertions and deletions in the underlying list do not.

This method can be used to apply an algorithm to a portion of a list. For example:

Algorithms.ReverseInPlace(deque.Range(3, 6))

will reverse the 6 items beginning at index 3.

Parameters
startThe starting index of the view.
countThe number of items in the view.
Returns
A list that is a view onto the given sub-part of this list.
Exceptions
ArgumentOutOfRangeExceptionstart or count is negative.
ArgumentOutOfRangeExceptionstart + count is greater than the size of the list.

Reimplemented in Wintellect.PowerCollections.BigList< T >.

override bool Wintellect.PowerCollections.ListBase< T >.Remove ( item)

Searches the list for the first item that compares equal to item . If one is found, it is removed. Otherwise, the list is unchanged.

Equality in the list is determined by the default sense of equality for T. If T implements IComparable<T>, the Equals method of that interface is used to determine equality. Otherwise, Object.Equals is used to determine equality.

Parameters
itemThe item to remove from the list.
Returns
True if an item was found and removed that compared equal to item . False if no such item was in the list.
abstract void Wintellect.PowerCollections.ListBase< T >.RemoveAt ( int  index)
pure virtual

This method must be overridden by the derived class to remove the item at the given index.

Parameters
indexThe index in the list to remove the item at. The first item in the list has index 0.
Exceptions
ArgumentOutOfRangeExceptionindex is less than zero or greater than or equal to Count.

Implemented in Wintellect.PowerCollections.Deque< T >, and Wintellect.PowerCollections.BigList< T >.

virtual bool Wintellect.PowerCollections.ListBase< T >.TryFind ( Predicate< T >  predicate,
out T  foundItem 
)
virtual

Finds the first item in the list that satisfies the condition defined by predicate .

Parameters
predicateA delegate that defines the condition to check for.
foundItemIf true is returned, this parameter receives the first item in the list that satifies the condition defined by predicate .
Returns
True if an item that satisfies the condition predicate was found. False if no item in the list satisfies that condition.
virtual bool Wintellect.PowerCollections.ListBase< T >.TryFindLast ( Predicate< T >  predicate,
out T  foundItem 
)
virtual

Finds the last item in the list that satisfies the condition defined by predicate .

Parameters
predicateA delegate that defines the condition to check for.
foundItemIf true is returned, this parameter receives the last item in the list that satifies the condition defined by predicate .
Returns
True if an item that satisfies the condition predicate was found. False if no item in the list satisfies that condition.

Property Documentation

abstract override int Wintellect.PowerCollections.ListBase< T >.Count
get

The property must be overridden by the derived class to return the number of items in the list.

The number of items in the list.

abstract T Wintellect.PowerCollections.ListBase< T >.this[int index]
getset

The indexer must be overridden by the derived class to get and set values of the list at a particular index.

Parameters
indexThe index in the list to get or set an item at. The first item in the list has index 0, and the last has index Count-1.
Returns
The item at the given index.
Exceptions
ArgumentOutOfRangeExceptionindex is less than zero or greater than or equal to Count.

The documentation for this class was generated from the following file: