Class ReadOnlyOrderedSet<T>
- Namespace
- NMF.Collections.Generic
- Assembly
- NMF.Collections.dll
Denotes a readonly ordered set view
public class ReadOnlyOrderedSet<T> : IList, ICollection, IOrderedSet<T>, IList<T>, ISet<T>, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
T
- Inheritance
-
ReadOnlyOrderedSet<T>
- Implements
-
IOrderedSet<T>IList<T>ISet<T>ICollection<T>IEnumerable<T>
- Derived
- Inherited Members
Constructors
ReadOnlyOrderedSet(OrderedSet<T>)
Creates a new instance
public ReadOnlyOrderedSet(OrderedSet<T> parent)
Parameters
parent
OrderedSet<T>The ordered set of which to create a view
Exceptions
- ArgumentNullException
Thrown if parent is null
Properties
Count
Gets the number of elements contained in the ICollection.
public int Count { get; }
Property Value
- int
The number of elements contained in the ICollection.
IsFixedSize
Gets a value indicating whether the IList has a fixed size.
public bool IsFixedSize { get; }
Property Value
IsReadOnly
Gets a value indicating whether the IList is read-only.
public bool IsReadOnly { get; }
Property Value
IsSynchronized
Gets a value indicating whether access to the ICollection is synchronized (thread safe).
public bool IsSynchronized { get; }
Property Value
- bool
true if access to the ICollection is synchronized (thread safe); otherwise, false.
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.
SyncRoot
Gets an object that can be used to synchronize access to the ICollection.
public object SyncRoot { get; }
Property Value
- object
An object that can be used to synchronize access to the ICollection.
Methods
Add(object)
Adds an item to the IList.
public int Add(object value)
Parameters
Returns
- int
The position into which the new element was inserted, or -1 to indicate that the item was not inserted into the collection.
Exceptions
- NotSupportedException
The IList is read-only.
-or-
The IList has a fixed size.
Add(T)
Adds an element to the current set and returns a value to indicate if the element was successfully added.
public bool Add(T item)
Parameters
item
TThe element to add to the set.
Returns
Clear()
Removes all items from the IList.
public void Clear()
Exceptions
- NotSupportedException
The IList is read-only.
Contains(object)
Determines whether the IList contains a specific value.
public bool Contains(object value)
Parameters
Returns
Contains(T)
Determines whether the ICollection<T> contains a specific value.
public bool Contains(T item)
Parameters
item
TThe object to locate in the ICollection<T>.
Returns
- bool
true if
item
is found in the ICollection<T>; otherwise, false.
CopyTo(Array, int)
Copies the elements of the ICollection to an Array, starting at a particular Array index.
public void CopyTo(Array array, int index)
Parameters
array
ArrayThe one-dimensional Array that is the destination of the elements copied from ICollection. The Array must have zero-based indexing.
index
intThe zero-based index in
array
at which copying begins.
Exceptions
- ArgumentNullException
array
is null.- ArgumentOutOfRangeException
index
is less than zero.- ArgumentException
<code class="paramref">array</code> is multidimensional.
-or-
The number of elements in the source ICollection is greater than the available space from
index
to the end of the destinationarray
.-or-
The type of the source ICollection cannot be cast automatically to the type of the destination
array
.
CopyTo(T[], int)
Copies the elements of the ICollection<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 ICollection<T>. The Array must have zero-based indexing.
arrayIndex
intThe zero-based index in
array
at which copying begins.
Exceptions
- ArgumentNullException
array
is null.- ArgumentOutOfRangeException
arrayIndex
is less than 0.- ArgumentException
The number of elements in the source ICollection<T> is greater than the available space from
arrayIndex
to the end of the destinationarray
.
ExceptWith(IEnumerable<T>)
Removes all elements in the specified collection from the current set.
public void ExceptWith(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection of items to remove from the set.
Exceptions
- ArgumentNullException
other
is null.
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.
IndexOf(object)
Determines the index of a specific item in the IList.
public int IndexOf(object value)
Parameters
Returns
- int
The index of
value
if found in the list; otherwise, -1.
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, object)
Inserts an item to the IList at the specified index.
public void Insert(int index, object value)
Parameters
index
intThe zero-based index at which
value
should be inserted.value
objectThe object to insert into the IList.
Exceptions
- ArgumentOutOfRangeException
index
is not a valid index in the IList.- NotSupportedException
The IList is read-only.
-or-
The IList has a fixed size.
- NullReferenceException
value
is null reference in the IList.
Insert(int, T)
Inserts an item to the IList<T> at the specified index.
public 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.
IntersectWith(IEnumerable<T>)
Modifies the current set so that it contains only elements that are also in a specified collection.
public void IntersectWith(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection to compare to the current set.
Exceptions
- ArgumentNullException
other
is null.
IsProperSubsetOf(IEnumerable<T>)
Determines whether the current set is a proper (strict) subset of a specified collection.
public bool IsProperSubsetOf(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
IsProperSupersetOf(IEnumerable<T>)
Determines whether the current set is a proper (strict) superset of a specified collection.
public bool IsProperSupersetOf(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
IsSubsetOf(IEnumerable<T>)
Determines whether a set is a subset of a specified collection.
public bool IsSubsetOf(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
IsSupersetOf(IEnumerable<T>)
Determines whether the current set is a superset of a specified collection.
public bool IsSupersetOf(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
Overlaps(IEnumerable<T>)
Determines whether the current set overlaps with the specified collection.
public bool Overlaps(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
Remove(object)
Removes the first occurrence of a specific object from the IList.
public void Remove(object value)
Parameters
Exceptions
- NotSupportedException
The IList is read-only.
-or-
The IList has a fixed size.
Remove(T)
Removes the first occurrence of a specific object from the ICollection<T>.
public 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.
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.
SetEquals(IEnumerable<T>)
Determines whether the current set and the specified collection contain the same elements.
public bool SetEquals(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
SymmetricExceptWith(IEnumerable<T>)
Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both.
public void SymmetricExceptWith(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection to compare to the current set.
Exceptions
- ArgumentNullException
other
is null.
UnionWith(IEnumerable<T>)
Modifies the current set so that it contains all elements that are present in the current set, in the specified collection, or in both.
public void UnionWith(IEnumerable<T> other)
Parameters
other
IEnumerable<T>The collection to compare to the current set.
Exceptions
- ArgumentNullException
other
is null.