Interface IMultiSet<T>
- Namespace
- LfrlAnvil.Collections
- Assembly
- LfrlAnvil.Collections.dll
Represents a generic multi set.
public interface IMultiSet<T> : IReadOnlyMultiSet<T>, IReadOnlySet<Pair<T, int>>, IReadOnlyCollection<Pair<T, int>>, ISet<Pair<T, int>>, ICollection<Pair<T, int>>, IEnumerable<Pair<T, int>>, IEnumerable where T : notnull
Type Parameters
T
Element type.
- Inherited Members
- Extension Methods
Properties
Count
Gets the number of elements contained in the ICollection<T>.
int Count { get; }
Property Value
- int
The number of elements contained in the ICollection<T>.
Methods
Add(T)
Adds the provided item
to this set once.
int Add(T item)
Parameters
item
TElement to add.
Returns
- int
Current multiplicity of the added
item
.
AddMany(T, int)
Adds the provided item
to this set with specified number of repetitions.
int AddMany(T item, int count)
Parameters
item
TElement to add.
count
intNumber of repetitions.
Returns
- int
Current multiplicity of the added
item
.
Exceptions
- ArgumentOutOfRangeException
When
count
is less than 1.
Contains(Pair<T, int>)
Determines whether the ICollection<T> contains a specific value.
[Pure]
bool Contains(Pair<T, int> item)
Parameters
item
Pair<T, int>The object to locate in the ICollection<T>.
Returns
- bool
true if
item
is found in the ICollection<T>; otherwise, false.
IsProperSubsetOf(IEnumerable<Pair<T, int>>)
Determines whether the current set is a proper (strict) subset of a specified collection.
[Pure]
bool IsProperSubsetOf(IEnumerable<Pair<T, int>> other)
Parameters
other
IEnumerable<Pair<T, int>>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
IsProperSupersetOf(IEnumerable<Pair<T, int>>)
Determines whether the current set is a proper (strict) superset of a specified collection.
[Pure]
bool IsProperSupersetOf(IEnumerable<Pair<T, int>> other)
Parameters
other
IEnumerable<Pair<T, int>>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
IsSubsetOf(IEnumerable<Pair<T, int>>)
Determines whether a set is a subset of a specified collection.
[Pure]
bool IsSubsetOf(IEnumerable<Pair<T, int>> other)
Parameters
other
IEnumerable<Pair<T, int>>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
IsSupersetOf(IEnumerable<Pair<T, int>>)
Determines whether the current set is a superset of a specified collection.
[Pure]
bool IsSupersetOf(IEnumerable<Pair<T, int>> other)
Parameters
other
IEnumerable<Pair<T, int>>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
Overlaps(IEnumerable<Pair<T, int>>)
Determines whether the current set overlaps with the specified collection.
[Pure]
bool Overlaps(IEnumerable<Pair<T, int>> other)
Parameters
other
IEnumerable<Pair<T, int>>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
Remove(T)
Removes the provided item
from this set once.
int Remove(T item)
Parameters
item
TElement to remove.
Returns
- int
Current multiplicity of the removed
item
or -1 if it did not exist.
RemoveAll(T)
Removes all occurrences of the provided item
from this set.
int RemoveAll(T item)
Parameters
item
TElement to remove.
Returns
- int
Removed number of repetitions or 0 if
item
did not exist.
RemoveMany(T, int)
Removes the provided item
from this set with specified number of repetitions.
int RemoveMany(T item, int count)
Parameters
item
TElement to remove.
count
intNumber of repetitions.
Returns
- int
Current multiplicity of the removed
item
or -1 if it did not exist.
Exceptions
- ArgumentOutOfRangeException
When
count
is less than 1.
SetEquals(IEnumerable<Pair<T, int>>)
Determines whether the current set and the specified collection contain the same elements.
[Pure]
bool SetEquals(IEnumerable<Pair<T, int>> other)
Parameters
other
IEnumerable<Pair<T, int>>The collection to compare to the current set.
Returns
Exceptions
- ArgumentNullException
other
is null.
SetMultiplicity(T, int)
Sets the number of repetitions for the provided item
in this set.
int SetMultiplicity(T item, int value)
Parameters
item
TElement to update.
value
intNumber of repetitions.
Returns
- int
Previous multiplicity of the updated
item
.
Remarks
Setting multiplicity to 0 is equivalent to RemoveAll(T) invocation.
Exceptions
- ArgumentOutOfRangeException
When
value
is less than 0.