Method Cut
Cut(IComparable<K>, out KeyValuePair<K, V>, out Boolean, out KeyValuePair<K, V>, out Boolean)
Given a "cut" function from the items of the sorted collection to
int
whose only sign changes when going through items in increasing order
can be
The "cut" function is supplied as the
CompareTo
method
of an object c
implementing
IComparable<K>
.
A typical example is the case where
K
is comparable and
c
is itself of type K
.
This method performs a search in the sorted collection for the ranges in which the "cut" function is negative, zero respectively positive. If
K
is comparable
and c
is of type K
, this is a safe way (no exceptions thrown)
to find predecessor and successor of c
.
If the supplied cut function does not satisfy the sign-change condition, the result of this call is undefined.
Declaration
bool Cut(IComparable<K> cutFunction, out KeyValuePair<K, V> lowEntry, out bool lowIsValid, out KeyValuePair<K, V> highEntry, out bool highIsValid)
Parameters
Type | Name | Description |
---|---|---|
IComparable<K> | cutFunction | The cut function to , given
by the method of an object implementing
. |
KeyValuePair<K, V> | lowEntry | Returns the largest item in the collection, where the cut function is positive (if any). |
System.Boolean | lowIsValid | Returns true if the cut function is positive somewhere on this collection. |
KeyValuePair<K, V> | highEntry | Returns the least item in the collection, where the cut function is negative (if any). |
System.Boolean | highIsValid | Returns true if the cut function is negative somewhere on this collection. |
Returns
Type | Description |
---|---|
System.Boolean | True if the cut function is zero somewhere on this collection. |