Represents an tokenized concurrent priority queue. Inserted items are associated with a token that can later be used to modify the item in the queue. There are two function sets to add queue items, depending on whether or not the queue is generating tokens by itself. Use Enqueue... functions, if the tokens are generated by the queue itself, or use Add.. functions if you provide the token.
Constructor | Description | ||
Full Usage:
ConcurrentTokenizedPriorityQueue()
|
Initializes a new instance of the ConcurrentTokenizedPriorityQueue class. This instance is not configured to generate tokens by itself, thus you must use the TryAdd(..) functions to enqueue items. |
||
Full Usage:
ConcurrentTokenizedPriorityQueue(initialCapacity)
Parameters:
int
-
The initial capacity of the queue.
|
Initializes a new instance of the ConcurrentTokenizedPriorityQueue class. This instance is not configured to generate tokens by itself, thus you must use the TryAdd(..) functions to enqueue items.
|
||
Full Usage:
ConcurrentTokenizedPriorityQueue(initialToken, GetNextToken)
Parameters:
'TToken
-
The initial token.
GetNextToken : Func<'TToken, 'TToken>
-
The function to generate new tokens. Argument is the old token. The return value should be a new token that was not generated before.
|
Initializes a new instance of the ConcurrentTokenizedPriorityQueue class. When argument GetNextToken is not null, the priority queue is generating new tokens by itself. In this case you should only use the Enqueue functions to enqueue items. In contrast, when GetNextToken is null, the priority queue is not generating tokens by itself, and you have to use the TryAdd(..) functions to enqueue items.
|
||
Full Usage:
ConcurrentTokenizedPriorityQueue(capacity, initialToken, GetNextToken)
Parameters:
int
-
The inital capacity of the priority queue.
initialToken : 'TToken
-
The initial token.
GetNextToken : Func<'TToken, 'TToken>
-
The function to generate new tokens. Argument is the old token. The return value should be a new token that was not generated before.
|
Initializes a new instance of the ConcurrentTokenizedPriorityQueue class. When argument GetNextToken is not null, the priority queue is generating new tokens by itself. In this case you should only use the Enqueue functions to enqueue items. In contrast, when GetNextToken is null, the priority queue is not generating tokens by itself, and you have to use the Add functions to enqueue items.
|
Instance member | Description | ||
Full Usage:
this.AddOrUpdate
Parameters:
'TToken
-
The token.
key : 'TKey
-
The key that should be added or updated
value : 'TValue
-
The value that should be added or updated
Returns: bool
True if the item was not present and therefore was added to the queue, false if the item was already present and therefore updated.
|
Adds a key/value pair associated with a token to the queue (if no such token is already present), or updates the already present key/value pair associated with the provided token.
|
||
Full Usage:
this.AddOrUpdate
Parameters:
'TToken
-
The token.
addValue : KeyValuePair<'TKey, 'TValue>
-
The key/value pair that should be added if the provided token is not present in the queue.
updateFactory : Func<'TToken, KeyValuePair<'TKey, 'TValue>, KeyValuePair<'TKey, 'TValue>>
-
A function that generates a new key/value pair that should be used to update the key/value pair associated with the provided token if it is already present in the queue.
Returns: KeyValuePair<'TKey, 'TValue>
The key/value pair that was used. Either the addValue, or the key/value pair used for update.
|
Adds a key/value pair associated with a token to the queue (if no such token is already present), or updates the already present key/value pair associated with the provided token.
|
||
Full Usage:
this.Clear
|
Removes all elements from this queue, resulting in an empty queue. |
||
Full Usage:
this.ContainsToken
Parameters:
'TToken
-
The token.
Returns: bool
True if the provided token exists in the queue; otherwise false .
|
Determines whether an item with the specified associated token exists in the queue.
|
||
Full Usage:
this.Count
Returns: int
|
Gets the number of elements in the priority queue.
|
||
Full Usage:
this.Dequeue
Returns: 'TKey * 'TValue
The key/value pair with minimum key value.
|
Dequeues the item with minimum key. If the queue is empty, an exception will be thrown.
|
||
Full Usage:
this.Enqueue
Parameters:
'TKey
-
The key.
value : 'TValue
-
The value.
token : byref<'TToken>
-
Returns a token associated with the enqueued key/value pair. The token can later be used to manipulate the entry in the queue.
|
Enqueues an item consisting of a key and a value. The priority queue has to be constructed to generate tokens by itself in order to use this function. Otherwise an exception is thrown.
|
||
Full Usage:
this.EnqueueOrUpdate
Parameters:
'TKey
-
The key that should be enqueued (if token not present in the queue) or updated (if token is already present in the queue).
value : 'TValue
-
The value that should be enqueued (if token not present in the queue) or updated (if token is already present in the queue).
token : byref<'TToken>
-
The token used to identify key/value pairs in the queue.
Returns: bool
True if the key/value pair was freshly enqueued, or false if the token was already present in the queue, and therefore the key/value pair was updated.
|
Adds a key/value pair associated with a token to the queue (if no such token is already present), or updates the already present key/value pair associated with the provided token.
|
||
Full Usage:
this.EnqueueOrUpdate
Parameters:
KeyValuePair<'TKey, 'TValue>
-
The key/value pair that should be enqueued if the provided token is not present in the queue.
token : byref<'TToken>
-
The token. On return, if the token was not in the queue, contains a new token that was freshly generated.
updateFactory : Func<'TToken, KeyValuePair<'TKey, 'TValue>, KeyValuePair<'TKey, 'TValue>>
-
A function that generates a new key/value pair that should be used to update the key/value pair associated with the provided token if it is already present in the queue.
Returns: KeyValuePair<'TKey, 'TValue>
The key/value pair that was used. Either the addValue, or the key/value pair used for update.
|
Adds a key/value pair associated with a token to the queue (if no such token is already present), or updates the already present key/value pair associated with the provided token.
|
||
Full Usage:
this.IsEmpty
Returns: bool
|
Gets a value indicating whether the priority queue is empty.
|
||
Full Usage:
this.TryAdd
Parameters:
'TToken
-
The token.
key : 'TKey
-
The key.
value : 'TValue
-
The value.
Returns: bool
True if the key/value pair could be added to the queue. False if the token already exists in the queue.
|
Tries to add the key/value pair associated with the provided token to the queue. The queue must not be configured to generate tokens by itself.
|
||
Full Usage:
this.TryDecreaseKey
Parameters:
'TToken
-
The token associated with the key.
key : 'TKey
-
The new key.
Returns: bool
True if the item associated with the token still existed in the queue; otherwise false .
|
Tries to change the key associated with the provided token. The new key value has to be less than the existing one; otherwise an exception is thrown.
|
||
Full Usage:
this.TryDequeue
Parameters:
byref<'TKey>
-
On sucessfull return, contains the minimum key value.
value : byref<'TValue>
-
On sucessfull return, contains value belonging to the minimum key value.
token : byref<'TToken>
-
On successfull return, contains the token associated with the key/value pair with minimum key.
Returns: bool
True if an item could be successfully retrieved from the queue; false if the queue contains no items.
|
Tries to dequeue the item with minimum key.
|
||
Full Usage:
this.TryGet
Parameters:
'TToken
-
The token.
key : byref<'TKey>
-
On sucessfull return, contains the key of the key/value pair associated with the token.
value : byref<'TValue>
-
On sucessfull return, contains the value of the key/value pair associated with the token.
Returns: bool
True if the key/value pair associated with the token existed in the queue. False if the a key/value pair associated with the provided token is not in the queue.
|
Tries to get the key/value pair that is associated with the provided token.
|
||
Full Usage:
this.TryGet
Parameters:
'TToken
-
The token.
key : byref<'TKey>
-
On sucessfull return, contains the key of the key/value pair associated with the token.
Returns: bool
True if the key/value pair associated with the token existed in the queue. False if the a key/value pair associated with the provided token is not in the queue.
|
Tries to get the key/value pair that is associated with the provided token.
|
||
Full Usage:
this.TryIncreaseKey
Parameters:
'TToken
-
The token.
key : 'TKey
-
The new key.
Returns: bool
True if the item associated with the token still existed in the queue; otherwise false .
|
Tries to change the key associated with the provided token. The new key value has to be greater than the existing one; otherwise an exception is thrown.
|
||
Full Usage:
this.TryPeek
Parameters:
byref<'TKey>
-
On successfull return, contains the minimum key.
value : byref<'TValue>
-
On successfull return, contains the value associated with the minimum key.
token : byref<'TToken>
-
On successfull return, contains the token associated with the minimum key.
Returns: bool
True if the queue contained at least one element that could be Peek'd; otherwise false .
|
Tries to retrieve the element with minimum key.
|
||
Full Usage:
this.TryPeek
Parameters:
byref<'TKey>
-
On successfull return, contains the minimum key.
value : byref<'TValue>
-
On successfull return, contains the value associated with the minimum key.
Returns: bool
True if the queue contained at least one element that could be Peek'd; otherwise false .
|
Tries to retrieve the element with minimum key.
|
||
Full Usage:
this.TryPeek
Parameters:
byref<'TKey>
-
On successfull return, contains the minimum key.
Returns: bool
True if the queue contained at least one element that could be Peek'd; otherwise false .
|
Tries to retrieve the element with minimum key.
|
||
Full Usage:
this.TryPeekKey
Parameters:
byref<'TKey>
Returns: bool
|
|
||
Full Usage:
this.TryRemove
Parameters:
'TToken
-
The token associated with the key/value pair to remove.
key : byref<'TKey>
-
On successfull return, contains the key of the removed key/value pair.
value : byref<'TValue>
-
On successfull return, contains the value of the removed key/value pair.
Returns: bool
True if the item still existed in the queue and could be successfully removed; otherwise false .
|
Tries to remove the key/value pair associated with the provided token from the queue (independently on the current position of the key/value pair in the queue).
|
||
Full Usage:
this.TryRemove
Parameters:
'TToken
-
The token associated with the key/value pair to remove.
key : byref<'TKey>
-
On successfull return, contains the key of the removed key/value pair.
Returns: bool
True if the item still existed in the queue and could be successfully removed; otherwise false .
|
Tries to remove the key/value pair associated with the provided token from the queue (independently on the current position of the key/value pair in the queue).
|
||
Full Usage:
this.TryRemove
Parameters:
'TToken
-
The token associated with the key/value pair to remove.
Returns: bool
True if the item still existed in the queue and could be successfully removed; otherwise false .
|
Tries to remove the key/value pair associated with the provided token from the queue (independently on the current position of the key/value pair in the queue).
|
||
Full Usage:
this.TryUpdateKey
Parameters:
'TToken
-
The token associated with the key.
key : 'TKey
-
The new key.
Returns: bool
True if the key/value pair associated with the token still existed in the queue; otherwise false .
|
Tries to update the key associated with the provided token. The value is left as is.
|