Class TreeSet<T>
An implementation of Red-Black trees as an indexed, sorted collection with set semantics, cf. CLRS. C5.TreeBag`1 for a version with bag semantics. C5.TreeDictionary`2 for a sorted dictionary based on this tree implementation. The comparer (sorting order) may be either natural, because the item type is comparable (generic: C5.IComparable`1 or non-generic: System.IComparable) or it can be external and supplied by the user in the constructor.
TODO: describe performance here TODO: discuss persistence and its useful usage modes. Warn about the space leak possible with other usage modes.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Support
Assembly: Lucene.Net.dll
Syntax
public class TreeSet<T> : SequencedBase<T>, IIndexedSorted<T>, IIndexed<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IPersistentSorted<T>, ISorted<T>, ISequenced<T>, ICollection<T>, IExtensible<T>, IDirectedCollectionValue<T>, ICollectionValue<T>, IShowable, IFormattable, IDirectedEnumerable<T>, IDisposable, ISet<T>, ICollection<T>, IEnumerable<T>, IEnumerable
Type Parameters
Name | Description |
---|---|
T |
Constructors
| Improve this Doc View SourceTreeSet(MemoryType)
Create a red-black tree collection with natural comparer and item equalityComparer. We assume that if
T
is comparable, its default equalityComparer
will be compatible with the comparer.
Declaration
public TreeSet(MemoryType memoryType = MemoryType.Normal)
Parameters
Type | Name | Description |
---|---|---|
MemoryType | memoryType |
Exceptions
Type | Condition |
---|---|
NotComparableException | If is not comparable.
|
TreeSet(IComparer<T>, MemoryType)
Create a red-black tree collection with an external comparer.
The itemequalityComparer will be a compatible C5.ComparerZeroHashCodeEqualityComparer`1 since the default equalityComparer for T (C5.EqualityComparer`1.Default) is unlikely to be compatible with the external comparer. This makes the tree inadequate for use as item in a collection of unsequenced or sequenced sets or bags (C5.ICollection`1 and C5.ISequenced`1)
Declaration
public TreeSet(IComparer<T> comparer, MemoryType memoryType = MemoryType.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IComparer<T> | comparer | The external comparer |
MemoryType | memoryType |
TreeSet(IComparer<T>, IEqualityComparer<T>, MemoryType)
Create a red-black tree collection with an external comparer and an external item equalityComparer, assumed consistent.
Declaration
public TreeSet(IComparer<T> comparer, IEqualityComparer<T> equalityComparer, MemoryType memoryType = MemoryType.Normal)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IComparer<T> | comparer | The external comparer |
System.Collections.Generic.IEqualityComparer<T> | equalityComparer | The external item equalitySCG.Comparer |
MemoryType | memoryType |
Properties
| Improve this Doc View SourceAllowsDuplicates
Declaration
public bool AllowsDuplicates { get; }
Property Value
Type | Description |
---|---|
System.Boolean | False since this tree has set semantics. |
Comparer
The comparer object supplied at creation time for this collection
Declaration
public IComparer<T> Comparer { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IComparer<T> | The comparer |
ContainsSpeed
The value is symbolic indicating the type of asymptotic complexity in terms of the size of this collection (worst-case or amortized as relevant).
Declaration
public Speed ContainsSpeed { get; }
Property Value
Type | Description |
---|---|
Speed | Speed.Log |
DuplicatesByCounting
By convention this is true for any collection with set semantics.
Declaration
public virtual bool DuplicatesByCounting { get; }
Property Value
Type | Description |
---|---|
System.Boolean | True if only one representative of a group of equal items is kept in the collection together with the total count. |
IndexingSpeed
Declaration
public virtual Speed IndexingSpeed { get; }
Property Value
Type | Description |
---|---|
Speed |
Item[Int32]
System.IndexOutOfRangeException if i is negative or
= the size of the collection.
Declaration
public T this[int i] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i | the index to lookup |
Property Value
Type | Description |
---|---|
T | The i'th item of this list. |
Item[Int32, Int32]
System.IndexOutOfRangeException.
Declaration
public IDirectedCollectionValue<T> this[int start, int count] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | start | The starting index of the interval (inclusive). |
System.Int32 | count | The length of the interval. |
Property Value
Type | Description |
---|---|
IDirectedCollectionValue<T> | The directed collection of items in a specific index interval. |
ListenableEvents
Declaration
public override EventTypeEnum ListenableEvents { get; }
Property Value
Type | Description |
---|---|
EventTypeEnum |
Overrides
Methods
| Improve this Doc View SourceAdd(T)
Add an item to this collection if possible. If this collection has set semantics, the item will be added if not already in the collection. If bag semantics, the item will always be added.
Declaration
public bool Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to add. |
Returns
Type | Description |
---|---|
System.Boolean | True if item was added. |
AddAll(IEnumerable<T>)
Add the elements from another collection with a more specialized item type to this collection. If this collection has set semantics, only items not already in the collection will be added.
Declaration
public void AddAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to add |
AddSorted(IEnumerable<T>)
Add all the items from another collection with an enumeration order that is increasing in the items.
The idea is that the implementation may use a faster algorithm to merge the two collections.
System.ArgumentException if the enumerated items turns out not to be in increasing order.Declaration
public void AddSorted(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The collection to add. |
Backwards()
Create a collection containing the same items as this collection, but whose enumerator will enumerate the items backwards. The new collection will become invalid if the original is modified. Method typically used as in
foreach (T x in coll.Backwards()) {...}
Declaration
public override IDirectedCollectionValue<T> Backwards()
Returns
Type | Description |
---|---|
IDirectedCollectionValue<T> | The backwards collection. |
Overrides
Check()
Checks red-black invariant. Dumps tree to console if bad
Declaration
public bool Check()
Returns
Type | Description |
---|---|
System.Boolean | false if invariant violation |
Check(String)
Checks red-black invariant. Dumps tree to console if bad
Declaration
public bool Check(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Title of dump |
Returns
Type | Description |
---|---|
System.Boolean | false if invariant violation |
Choose()
Declaration
public override T Choose()
Returns
Type | Description |
---|---|
T |
Overrides
Exceptions
Type | Condition |
---|---|
NoSuchItemException | If tree is empty |
Clear()
Remove all items from this collection.
Declaration
public void Clear()
Contains(T)
Check if this collection contains (an item equivalent to according to the itemequalityComparer) a particular value.
Declaration
public bool Contains(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to check for. |
Returns
Type | Description |
---|---|
System.Boolean | True if the items is in this collection. |
ContainsAll(IEnumerable<T>)
Check if this collection contains all the values in another collection. If this collection has bag semantics (
AllowsDuplicates==true
)
the check is made with respect to multiplicities, else multiplicities
are not taken into account.
Declaration
public bool ContainsAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The |
Returns
Type | Description |
---|---|
System.Boolean | True if all values in is in this collection.
|
ContainsCount(T)
Count the number of items of the collection equal to a particular value. Returns 0 if and only if the value is not in the collection.
Declaration
public int ContainsCount(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to count. |
Returns
Type | Description |
---|---|
System.Int32 | The number of copies found. |
CountFrom(T)
Determine the number of items at or above a supplied threshold.
Declaration
public int CountFrom(T bot)
Parameters
Type | Name | Description |
---|---|---|
T | bot | The lower bound (inclusive) |
Returns
Type | Description |
---|---|
System.Int32 | The number of matching items. |
CountFromTo(T, T)
Determine the number of items between two supplied thresholds.
Declaration
public int CountFromTo(T bot, T top)
Parameters
Type | Name | Description |
---|---|---|
T | bot | The lower bound (inclusive) |
T | top | The upper bound (exclusive) |
Returns
Type | Description |
---|---|
System.Int32 | The number of matching items. |
CountTo(T)
Determine the number of items below a supplied threshold.
Declaration
public int CountTo(T top)
Parameters
Type | Name | Description |
---|---|---|
T | top | The upper bound (exclusive) |
Returns
Type | Description |
---|---|
System.Int32 | The number of matching items. |
Cut(IComparable<T>, out T, out Boolean, out T, out Boolean)
Perform a search in the sorted collection for the ranges in which a non-increasing (i.e. weakly decreasing) function from the item type to
int
is
negative, zero respectively positive. If the supplied cut function is not non-increasing, the result of this call is undefined.
Declaration
public bool Cut(IComparable<T> c, out T low, out bool lowIsValid, out T high, out bool highIsValid)
Parameters
Type | Name | Description |
---|---|---|
System.IComparable<T> | c | The cut function to , given
as an object, where the cut function is
the method.
|
T | low | Returns the largest item in the collection, where the cut function is positive (if any). |
System.Boolean | lowIsValid | True if the cut function is positive somewhere on this collection. |
T | high | Returns the least item in the collection, where the cut function is negative (if any). |
System.Boolean | highIsValid | True if the cut function is negative somewhere on this collection. |
Returns
Type | Description |
---|---|
System.Boolean |
DeleteMax()
Remove the largest item from this priority queue.
Declaration
public T DeleteMax()
Returns
Type | Description |
---|---|
T | The removed item. |
DeleteMin()
Remove the least item from this priority queue.
Declaration
public T DeleteMin()
Returns
Type | Description |
---|---|
T | The removed item. |
Dispose()
If this tree is a snapshot, remove registration in base tree
Declaration
public void Dispose()
dump()
Print the tree structure to the console stdout.
Declaration
public void dump()
dump(String)
Print the tree structure to the console stdout.
Declaration
public void dump(string msg)
Parameters
Type | Name | Description |
---|---|---|
System.String | msg |
ExceptWith(IEnumerable<T>)
Not implemented
Declaration
public void ExceptWith(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other |
Find(ref T)
Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, return in the ref argument (a binary copy of) the actual value found.
Declaration
public bool Find(ref T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to look for. |
Returns
Type | Description |
---|---|
System.Boolean | True if the items is in this collection. |
FindAll(Func<T, Boolean>)
Create a new indexed sorted collection consisting of the items of this indexed sorted collection satisfying a certain predicate.
Declaration
public IIndexedSorted<T> FindAll(Func<T, bool> filter)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, System.Boolean> | filter | The filter delegate defining the predicate. |
Returns
Type | Description |
---|---|
IIndexedSorted<T> | The new indexed sorted collection. |
FindMax()
Find the current largest item of this priority queue.
Declaration
public T FindMax()
Returns
Type | Description |
---|---|
T | The largest item. |
FindMin()
Find the current least item of this priority queue.
Declaration
public T FindMin()
Returns
Type | Description |
---|---|
T | The least item. |
FindOrAdd(ref T)
Find or add the item to the tree. If the tree does not contain an item equivalent to this item add it, else return the existing one in the ref argument.
Declaration
public bool FindOrAdd(ref T item)
Parameters
Type | Name | Description |
---|---|---|
T | item |
Returns
Type | Description |
---|---|
System.Boolean | True if item was found |
GetEnumerator()
Create an enumerator for this tree
Declaration
public override IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> | The enumerator |
Overrides
IndexOf(T)
Searches for an item in this indexed collection going forwards from the start.
Declaration
public int IndexOf(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to search for. |
Returns
Type | Description |
---|---|
System.Int32 | Index of first occurrence from start of the item if found, else the two-complement (always negative) of the index at which the item would be put if it was added. |
IntersectWith(IEnumerable<T>)
Not implemented
Declaration
public void IntersectWith(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other |
IsProperSubsetOf(IEnumerable<T>)
Determines whether a TreeSet<T> object is a proper subset of the specified collection.
Declaration
public bool IsProperSubsetOf(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current TreeSet<T> object. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsProperSupersetOf(IEnumerable<T>)
Determines whether a TreeSet<T> object is a proper superset of the specified collection.
Declaration
public bool IsProperSupersetOf(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current TreeSet<T> object. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsSubsetOf(IEnumerable<T>)
Determines whether a TreeSet<T> object is a subset of the specified collection.
Declaration
public bool IsSubsetOf(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current TreeSet<T> object. |
Returns
Type | Description |
---|---|
System.Boolean |
|
IsSupersetOf(IEnumerable<T>)
Determines whether a TreeSet<T> object is a superset of the specified collection.
Declaration
public bool IsSupersetOf(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current TreeSet<T> object. |
Returns
Type | Description |
---|---|
System.Boolean |
|
ItemMultiplicities()
Declaration
public virtual ICollectionValue<KeyValuePair<T, int>> ItemMultiplicities()
Returns
Type | Description |
---|---|
ICollectionValue<KeyValuePair<T, System.Int32>> |
LastIndexOf(T)
Searches for an item in the tree going backwards from the end.
Declaration
public int LastIndexOf(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Item to search for. |
Returns
Type | Description |
---|---|
System.Int32 | Index of last occurrence from the end of item if found, else the two-complement (always negative) of the index at which the item would be put if it was added. |
Map<V>(Func<T, V>, IComparer<V>)
Create a new indexed sorted collection consisting of the results of mapping all items of this list. System.ArgumentException if the map is not increasing over the items of this collection (with respect to the two given comparison relations).
Declaration
public IIndexedSorted<V> Map<V>(Func<T, V> mapper, IComparer<V> c)
Parameters
Type | Name | Description |
---|---|---|
System.Func<T, V> | mapper | The delegate definging the map. |
System.Collections.Generic.IComparer<V> | c | The comparion relation to use for the result. |
Returns
Type | Description |
---|---|
IIndexedSorted<V> | The new sorted collection. |
Type Parameters
Name | Description |
---|---|
V |
Overlaps(IEnumerable<T>)
Determines whether the current TreeSet<T> object and a specified collection share common elements.
Declaration
public bool Overlaps(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current TreeSet<T> object. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Predecessor(T)
Find the strict predecessor in the sorted collection of a particular value, i.e. the largest item in the collection less than the supplied value.
Declaration
public T Predecessor(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to find the predecessor for. |
Returns
Type | Description |
---|---|
T | The predecessor. |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if no such element exists (the supplied value is less than or equal to the minimum of this collection.) |
RangeAll()
Create a directed collection with the same items as this collection.
Declaration
public IDirectedCollectionValue<T> RangeAll()
Returns
Type | Description |
---|---|
IDirectedCollectionValue<T> | The result directed collection. |
RangeFrom(T)
Query this sorted collection for items greater than or equal to a supplied value.
Declaration
public IDirectedCollectionValue<T> RangeFrom(T bot)
Parameters
Type | Name | Description |
---|---|---|
T | bot | The lower bound (inclusive). |
Returns
Type | Description |
---|---|
IDirectedCollectionValue<T> | The result directed collection. |
RangeFromTo(T, T)
Query this sorted collection for items between two supplied values.
Declaration
public IDirectedCollectionValue<T> RangeFromTo(T bot, T top)
Parameters
Type | Name | Description |
---|---|---|
T | bot | The lower bound (inclusive). |
T | top | The upper bound (exclusive). |
Returns
Type | Description |
---|---|
IDirectedCollectionValue<T> | The result directed collection. |
RangeTo(T)
Query this sorted collection for items less than a supplied value.
Declaration
public IDirectedCollectionValue<T> RangeTo(T top)
Parameters
Type | Name | Description |
---|---|---|
T | top | The upper bound (exclusive). |
Returns
Type | Description |
---|---|
IDirectedCollectionValue<T> | The result directed collection. |
Remove(T)
Remove a particular item from this collection. If the collection has bag semantics only one copy equivalent to the supplied item is removed.
Declaration
public bool Remove(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to remove. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found (and removed). |
Remove(T, out T)
Remove a particular item from this collection if found. If the collection has bag semantics only one copy equivalent to the supplied item is removed, which one is implementation dependent. If an item was removed, report a binary copy of the actual item removed in the argument.
Declaration
public bool Remove(T item, out T removeditem)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to remove. |
T | removeditem | The removed value. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found (and removed). |
RemoveAll(IEnumerable<T>)
Remove all items in another collection from this one. If this collection has bag semantics, take multiplicities into account.
Declaration
public void RemoveAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to remove. |
RemoveAllCopies(T)
Remove all items equivalent to a given value.
Declaration
public void RemoveAllCopies(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The value to remove. |
RemoveAt(Int32)
Remove the item at a specific position of the list. System.IndexOutOfRangeException if i is negative or
= the size of the collection.
Declaration
public T RemoveAt(int i)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | i | The index of the item to remove. |
Returns
Type | Description |
---|---|
T | The removed item. |
RemoveInterval(Int32, Int32)
Remove all items in an index interval. System.IndexOutOfRangeException???.
Declaration
public void RemoveInterval(int start, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | start | The index of the first item to remove. |
System.Int32 | count | The number of items to remove. |
RemoveRangeFrom(T)
Remove all items of this collection above or at a supplied threshold.
Declaration
public void RemoveRangeFrom(T low)
Parameters
Type | Name | Description |
---|---|---|
T | low | The lower threshold (inclusive). |
RemoveRangeFromTo(T, T)
Remove all items of this collection between two supplied thresholds.
Declaration
public void RemoveRangeFromTo(T low, T hi)
Parameters
Type | Name | Description |
---|---|---|
T | low | The lower threshold (inclusive). |
T | hi | The upper threshold (exclusive). |
RemoveRangeTo(T)
Remove all items of this collection below a supplied threshold.
Declaration
public void RemoveRangeTo(T hi)
Parameters
Type | Name | Description |
---|---|---|
T | hi | The upper threshold (exclusive). |
RetainAll(IEnumerable<T>)
Remove all items not in some other collection from this one. If this collection has bag semantics, take multiplicities into account.
Declaration
public void RetainAll(IEnumerable<T> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | items | The items to retain. |
SetEquals(IEnumerable<T>)
Determines whether the current TreeSet<T> and the specified collection contain the same elements.
Declaration
public bool SetEquals(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other | The collection to compare to the current TreeSet<T>. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Snapshot()
Make a (read-only) snapshot of this collection.
Declaration
public ISorted<T> Snapshot()
Returns
Type | Description |
---|---|
ISorted<T> | The snapshot. |
Successor(T)
Find the strict successor in the sorted collection of a particular value, i.e. the least item in the collection greater than the supplied value.
Declaration
public T Successor(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to find the successor for. |
Returns
Type | Description |
---|---|
T | The successor. |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if no such element exists (the supplied value is greater than or equal to the maximum of this collection.) |
SymmetricExceptWith(IEnumerable<T>)
Not implemented
Declaration
public void SymmetricExceptWith(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other |
TryPredecessor(T, out T)
Find the strict predecessor of item in the sorted collection, that is, the greatest item in the collection smaller than the item.
Declaration
public bool TryPredecessor(T item, out T res)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to find the predecessor for. |
T | res | The predecessor, if any; otherwise the default value for T. |
Returns
Type | Description |
---|---|
System.Boolean | True if item has a predecessor; otherwise false. |
TrySuccessor(T, out T)
Find the strict successor of item in the sorted collection, that is, the least item in the collection greater than the supplied value.
Declaration
public bool TrySuccessor(T item, out T res)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to find the successor for. |
T | res | The successor, if any; otherwise the default value for T. |
Returns
Type | Description |
---|---|
System.Boolean | True if item has a successor; otherwise false. |
TryWeakPredecessor(T, out T)
Find the weak predecessor of item in the sorted collection, that is, the greatest item in the collection smaller than or equal to the item.
Declaration
public bool TryWeakPredecessor(T item, out T res)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to find the weak predecessor for. |
T | res | The weak predecessor, if any; otherwise the default value for T. |
Returns
Type | Description |
---|---|
System.Boolean | True if item has a weak predecessor; otherwise false. |
TryWeakSuccessor(T, out T)
Find the weak successor of item in the sorted collection, that is, the least item in the collection greater than or equal to the supplied value.
Declaration
public bool TryWeakSuccessor(T item, out T res)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to find the weak successor for. |
T | res | The weak successor, if any; otherwise the default value for T. |
Returns
Type | Description |
---|---|
System.Boolean | True if item has a weak successor; otherwise false. |
UnionWith(IEnumerable<T>)
Modifies the current TreeSet<T> object to contain all elements that are present in itself, the specified collection, or both.
Declaration
public void UnionWith(IEnumerable<T> other)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<T> | other |
UniqueItems()
Declaration
public virtual ICollectionValue<T> UniqueItems()
Returns
Type | Description |
---|---|
ICollectionValue<T> |
Update(T)
Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection to with a binary copy of the supplied value. If the collection has bag semantics, this updates all equivalent copies in the collection.
Declaration
public bool Update(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Value to update. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found and hence updated. |
Update(T, out T)
Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection with a binary copy of the supplied value. If the collection has bag semantics, this updates all equivalent copies in the collection.
Declaration
public bool Update(T item, out T olditem)
Parameters
Type | Name | Description |
---|---|---|
T | item | |
T | olditem |
Returns
Type | Description |
---|---|
System.Boolean |
UpdateOrAdd(T)
Check if this collection contains an item equivalent according to the itemequalityComparer to a particular value. If so, update the item in the collection with a binary copy of the supplied value; else add the value to the collection.
NOTE: the bag implementation is currently wrong! ?????
Declaration
public bool UpdateOrAdd(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | Value to add or update. |
Returns
Type | Description |
---|---|
System.Boolean | True if the item was found and updated (hence not added). |
UpdateOrAdd(T, out T)
Declaration
public bool UpdateOrAdd(T item, out T olditem)
Parameters
Type | Name | Description |
---|---|---|
T | item | |
T | olditem |
Returns
Type | Description |
---|---|
System.Boolean |
WeakPredecessor(T)
Find the weak predecessor in the sorted collection of a particular value, i.e. the largest item in the collection less than or equal to the supplied value.
Declaration
public T WeakPredecessor(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to find the weak predecessor for. |
Returns
Type | Description |
---|---|
T | The weak predecessor. |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if no such element exists (the supplied value is less than the minimum of this collection.) |
WeakSuccessor(T)
Find the weak successor in the sorted collection of a particular value, i.e. the least item in the collection greater than or equal to the supplied value. NoSuchItemException
Declaration
public T WeakSuccessor(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to find the weak successor for. |
Returns
Type | Description |
---|---|
T | The weak successor. |
Explicit Interface Implementations
| Improve this Doc View SourceIDirectedEnumerable<T>.Backwards()
Declaration
IDirectedEnumerable<T> IDirectedEnumerable<T>.Backwards()
Returns
Type | Description |
---|---|
IDirectedEnumerable<T> |
ISorted<T>.RangeFrom(T)
Declaration
IDirectedEnumerable<T> ISorted<T>.RangeFrom(T bot)
Parameters
Type | Name | Description |
---|---|---|
T | bot |
Returns
Type | Description |
---|---|
IDirectedEnumerable<T> |
ISorted<T>.RangeFromTo(T, T)
Declaration
IDirectedEnumerable<T> ISorted<T>.RangeFromTo(T bot, T top)
Parameters
Type | Name | Description |
---|---|---|
T | bot | |
T | top |
Returns
Type | Description |
---|---|
IDirectedEnumerable<T> |
ISorted<T>.RangeTo(T)
Declaration
IDirectedEnumerable<T> ISorted<T>.RangeTo(T top)
Parameters
Type | Name | Description |
---|---|---|
T | top |
Returns
Type | Description |
---|---|
IDirectedEnumerable<T> |
ICollection<T>.Add(T)
Add an item to this collection if possible. If this collection has set semantics, the item will be added if not already in the collection. If bag semantics, the item will always be added.
Declaration
void ICollection<T>.Add(T item)
Parameters
Type | Name | Description |
---|---|---|
T | item | The item to add. |