Class OrderedSet<T>
- Namespace
- NMF.Collections.Generic
- Assembly
- NMF.Collections.dll
Denotes an implementation of an ordered set
public class OrderedSet<T> : DecoratedSet<T>, IList, ICollection, IOrderedSet<T>, IList<T>, ISet<T>, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
- Inheritance
-
DecoratedSet<T>OrderedSet<T>
- Implements
-
IOrderedSet<T>IList<T>ISet<T>ICollection<T>IEnumerable<T>
- Derived
- Inherited Members
Properties
this[int]
Gets or sets the element at the specified index.
public T this[int index] { get; set; }
Parameters
index
intThe zero-based index of the element to get or set.
Property Value
- T
The element at the specified index.
Exceptions
- ArgumentOutOfRangeException
index
is not a valid index in the IList<T>.- NotSupportedException
The property is set and the IList<T> is read-only.
Methods
Add(T)
Adds an element to the current set and returns a value to indicate if the element was successfully added.
public override bool Add(T item)
Parameters
item
TThe element to add to the set.
Returns
AsReadOnly()
Returns a readonly view of the oredered set
public ReadOnlyOrderedSet<T> AsReadOnly()
Returns
Clear()
Removes all items from the ICollection<T>.
public override void Clear()
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
GetEnumerator()
Returns an enumerator that iterates through the collection.
public override IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator that can be used to iterate through the collection.
IndexOf(T)
Determines the index of a specific item in the IList<T>.
public int IndexOf(T item)
Parameters
item
TThe object to locate in the IList<T>.
Returns
- int
The index of
item
if found in the list; otherwise, -1.
Insert(int, T)
Inserts an item to the IList<T> at the specified index.
public virtual void Insert(int index, T item)
Parameters
index
intThe zero-based index at which
item
should be inserted.item
TThe object to insert into the IList<T>.
Exceptions
- ArgumentOutOfRangeException
index
is not a valid index in the IList<T>.- NotSupportedException
The IList<T> is read-only.
Remove(T)
Removes the first occurrence of a specific object from the ICollection<T>.
public override sealed bool Remove(T item)
Parameters
item
TThe object to remove from the ICollection<T>.
Returns
- bool
true if
item
was successfully removed from the ICollection<T>; otherwise, false. This method also returns false ifitem
is not found in the original ICollection<T>.
Exceptions
- NotSupportedException
The ICollection<T> is read-only.
Remove(T, int)
Removes the given item at the given arrayIndex
protected virtual bool Remove(T item, int index)
Parameters
item
TThe item to remove
index
intThe arrayIndex of the item
Returns
- bool
True, if the removal was successful, otherwise false
RemoveAt(int)
Removes the IList item at the specified index.
public void RemoveAt(int index)
Parameters
index
intThe zero-based index of the item to remove.
Exceptions
- ArgumentOutOfRangeException
index
is not a valid index in the IList.- NotSupportedException
The IList is read-only.
-or-
The IList has a fixed size.
Replace(int, T, T)
Replaces the item at the given arrayIndex
protected virtual void Replace(int index, T oldValue, T newValue)
Parameters
index
intThe arrayIndex on which the item is replaced
oldValue
TThe old value
newValue
TThe new value