Class ConditionalCollection<T>
- Namespace
- Cuemon.Collections.Generic
- Assembly
- Cuemon.Core.dll
Provides the abstract base class for a generic, conditional collection.
public abstract class ConditionalCollection<T> : ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
The type of elements in the collection.
- Inheritance
-
ConditionalCollection<T>
- Implements
-
ICollection<T>IEnumerable<T>
Constructors
ConditionalCollection()
Initializes a new instance of the ConditionalCollection<T> class.
protected ConditionalCollection()
Properties
Count
Gets the number of elements contained in the ConditionalCollection<T>.
public int Count { get; }
Property Value
- Int32
The number of elements actually contained in the ConditionalCollection<T>.
IsReadOnly
Gets a value indicating whether the ConditionalCollection<T> is read-only.
public bool IsReadOnly { get; }
Property Value
- Boolean
true
if this instance is read only; otherwise,false
.
Methods
Add(T)
Adds an item to the ConditionalCollection<T>.
public abstract void Add(T item)
Parameters
item
TThe object to add to the ConditionalCollection<T>.
Add(T, Action)
Adds an item to the ConditionalCollection<T>.
protected void Add(T item, Action validator)
Parameters
item
TThe object to add to the ConditionalCollection<T>.
validator
ActionThe delegate that validates the
item
being added to the ConditionalCollection<T>.
Clear()
Removes all items from the ConditionalCollection<T>.
public void Clear()
Contains(T)
Determines whether the ConditionalCollection<T> contains a specific value.
public abstract bool Contains(T item)
Parameters
item
TThe object to locate in the ConditionalCollection<T>.
Returns
- Boolean
true
ifitem
is found in the ConditionalCollection<T>; otherwise,false
.
Contains(T, IEqualityComparer<T>)
Determines whether the ConditionalCollection<T> contains a specific value by using a specified comparer
.
protected bool Contains(T item, IEqualityComparer<T> comparer)
Parameters
item
TThe object to locate in the ConditionalCollection<T>.
comparer
IEqualityComparer<T>The IEqualityComparer<T> implementation to use when comparing the specified
item
with an element from the ConditionalCollection<T>.
Returns
- Boolean
true
ifitem
is found in the ConditionalCollection<T>; otherwise,false
.
CopyTo(T[], Int32)
Copies the elements of the ConditionalCollection<T> to an Array, starting at a particular Array index.
public void CopyTo(T[] array, int arrayIndex)
Parameters
array
T[]The one-dimensional Array that is the destination of the elements copied from ConditionalCollection<T>. The Array must have zero-based indexing.
arrayIndex
Int32The zero-based index in
array
at which copying begins.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator that can be used to iterate through the collection.
Remove(T)
Removes the first occurrence of a specific object from the ConditionalCollection<T>.
public abstract bool Remove(T item)
Parameters
item
TThe object to remove from the ConditionalCollection<T>.
Returns
- Boolean
true
ifitem
was successfully removed from the ConditionalCollection<T>; otherwise,false
. This method also returns false ifitem
is not found in the original ConditionalCollection<T>.
Remove(T, Func<T, Boolean>, IEqualityComparer<T>)
Removes all occurrences of a specific object from the ConditionalCollection<T> that match the conditions defined by the specified predicate
and comparer
.
protected bool Remove(T item, Func<T, bool> predicate, IEqualityComparer<T> comparer = null)
Parameters
item
TThe object to remove from the ConditionalCollection<T>.
predicate
Func<T, Boolean>The function delegate that will iterate and match the specified
item
from the ConditionalCollection<T>.comparer
IEqualityComparer<T>The IEqualityComparer<T> implementation to use when comparing the specified
item
with an element from the ConditionalCollection<T>.
Returns
- Boolean
true
ifitem
was successfully removed from the ConditionalCollection<T>; otherwise,false
. This method also returns false ifitem
is not found in the original ConditionalCollection<T>.
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Returns an enumerator that iterates through a collection.
IEnumerator IEnumerable.GetEnumerator()
Returns
- IEnumerator
An IEnumerator object that can be used to iterate through the collection.