Interface ISortedDictionary<K, V>
A dictionary with sorted keys.
Inherited Members
Namespace: Lucene.Net.Support.C5
Assembly: Lucene.Net.dll
Syntax
public interface ISortedDictionary<K, V> : IDictionary<K, V>, ICollectionValue<KeyValuePair<K, V>>, IEnumerable<KeyValuePair<K, V>>, IEnumerable, IShowable, IFormattable
Type Parameters
Name | Description |
---|---|
K | |
V |
Properties
| Improve this Doc View SourceComparer
The key comparer used by this dictionary.
Declaration
IComparer<K> Comparer { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IComparer<K> |
Keys
Declaration
ISorted<K> Keys { get; }
Property Value
Type | Description |
---|---|
ISorted<K> |
Methods
| Improve this Doc View SourceAddSorted(IEnumerable<KeyValuePair<K, V>>)
Add all the items from another collection with an enumeration order that is increasing in the items.
Declaration
void AddSorted(IEnumerable<KeyValuePair<K, V>> items)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<KeyValuePair<K, V>> | items | The collection to add. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | if the enumerated items turns out not to be in increasing order. |
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 |
---|---|---|
System.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. |
DeleteMax()
Remove the largest item from this sorted collection.
Declaration
KeyValuePair<K, V> DeleteMax()
Returns
Type | Description |
---|---|
KeyValuePair<K, V> | The removed item. |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if the collection is empty. |
DeleteMin()
Remove the least item from this sorted collection.
Declaration
KeyValuePair<K, V> DeleteMin()
Returns
Type | Description |
---|---|
KeyValuePair<K, V> | The removed item. |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if the collection is empty. |
FindMax()
Find the current largest item of this sorted collection.
Declaration
KeyValuePair<K, V> FindMax()
Returns
Type | Description |
---|---|
KeyValuePair<K, V> | The largest item. |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if the collection is empty. |
FindMin()
Find the current least item of this sorted collection.
Declaration
KeyValuePair<K, V> FindMin()
Returns
Type | Description |
---|---|
KeyValuePair<K, V> | The least item. |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if the collection is empty. |
Predecessor(K)
Find the entry with the largest key less than a given key.
Declaration
KeyValuePair<K, V> Predecessor(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key to compare to |
Returns
Type | Description |
---|---|
KeyValuePair<K, V> | The entry |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if there is no such entry. |
RangeAll()
Create a directed collection with the same items as this collection.
The returned collection is not a copy but a view into the collection.
The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.
Declaration
IDirectedCollectionValue<KeyValuePair<K, V>> RangeAll()
Returns
Type | Description |
---|---|
IDirectedCollectionValue<KeyValuePair<K, V>> | The result directed collection. |
RangeFrom(K)
Query this sorted collection for items greater than or equal to a supplied value.
The returned collection is not a copy but a view into the collection.
The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.
Declaration
IDirectedEnumerable<KeyValuePair<K, V>> RangeFrom(K bot)
Parameters
Type | Name | Description |
---|---|---|
K | bot | The lower bound (inclusive). |
Returns
Type | Description |
---|---|
IDirectedEnumerable<KeyValuePair<K, V>> | The result directed collection. |
RangeFromTo(K, K)
Query this sorted collection for items between two supplied values.
The returned collection is not a copy but a view into the collection.
The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.
Declaration
IDirectedEnumerable<KeyValuePair<K, V>> RangeFromTo(K lowerBound, K upperBound)
Parameters
Type | Name | Description |
---|---|---|
K | lowerBound | The lower bound (inclusive). |
K | upperBound | The upper bound (exclusive). |
Returns
Type | Description |
---|---|
IDirectedEnumerable<KeyValuePair<K, V>> | The result directed collection. |
RangeTo(K)
Query this sorted collection for items less than a supplied value.
The returned collection is not a copy but a view into the collection.
The view is fragile in the sense that changes to the underlying collection will invalidate the view so that further operations on the view throws InvalidView exceptions.
Declaration
IDirectedEnumerable<KeyValuePair<K, V>> RangeTo(K top)
Parameters
Type | Name | Description |
---|---|---|
K | top | The upper bound (exclusive). |
Returns
Type | Description |
---|---|
IDirectedEnumerable<KeyValuePair<K, V>> | The result directed collection. |
RemoveRangeFrom(K)
Remove all items of this collection above or at a supplied threshold.
Declaration
void RemoveRangeFrom(K low)
Parameters
Type | Name | Description |
---|---|---|
K | low | The lower threshold (inclusive). |
RemoveRangeFromTo(K, K)
Remove all items of this collection between two supplied thresholds.
Declaration
void RemoveRangeFromTo(K low, K hi)
Parameters
Type | Name | Description |
---|---|---|
K | low | The lower threshold (inclusive). |
K | hi | The upper threshold (exclusive). |
RemoveRangeTo(K)
Remove all items of this collection below a supplied threshold.
Declaration
void RemoveRangeTo(K hi)
Parameters
Type | Name | Description |
---|---|---|
K | hi | The upper threshold (exclusive). |
Successor(K)
Find the entry with the least key greater than a given key.
Declaration
KeyValuePair<K, V> Successor(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key to compare to |
Returns
Type | Description |
---|---|
KeyValuePair<K, V> | The entry |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if there is no such entry. |
TryPredecessor(K, out KeyValuePair<K, V>)
Find the entry in the dictionary whose key is the predecessor of the specified key.
Declaration
bool TryPredecessor(K key, out KeyValuePair<K, V> res)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key |
KeyValuePair<K, V> | res | The predecessor, if any |
Returns
Type | Description |
---|---|
System.Boolean | True if key has a predecessor |
TrySuccessor(K, out KeyValuePair<K, V>)
Find the entry in the dictionary whose key is the successor of the specified key.
Declaration
bool TrySuccessor(K key, out KeyValuePair<K, V> res)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key |
KeyValuePair<K, V> | res | The successor, if any |
Returns
Type | Description |
---|---|
System.Boolean | True if the key has a successor |
TryWeakPredecessor(K, out KeyValuePair<K, V>)
Find the entry in the dictionary whose key is the weak predecessor of the specified key.
Declaration
bool TryWeakPredecessor(K key, out KeyValuePair<K, V> res)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key |
KeyValuePair<K, V> | res | The predecessor, if any |
Returns
Type | Description |
---|---|
System.Boolean | True if key has a weak predecessor |
TryWeakSuccessor(K, out KeyValuePair<K, V>)
Find the entry in the dictionary whose key is the weak successor of the specified key.
Declaration
bool TryWeakSuccessor(K key, out KeyValuePair<K, V> res)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key |
KeyValuePair<K, V> | res | The weak successor, if any |
Returns
Type | Description |
---|---|
System.Boolean | True if the key has a weak successor |
WeakPredecessor(K)
Find the entry with the largest key less than or equal to a given key.
Declaration
KeyValuePair<K, V> WeakPredecessor(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key to compare to |
Returns
Type | Description |
---|---|
KeyValuePair<K, V> | The entry |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if there is no such entry. |
WeakSuccessor(K)
Find the entry with the least key greater than or equal to a given key.
Declaration
KeyValuePair<K, V> WeakSuccessor(K key)
Parameters
Type | Name | Description |
---|---|---|
K | key | The key to compare to |
Returns
Type | Description |
---|---|
KeyValuePair<K, V> | The entry |
Exceptions
Type | Condition |
---|---|
NoSuchItemException | if there is no such entry. |