ConcurrentTokenizedPriorityQueue<'TKey, 'TValue, 'TToken> Type

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.

Constructors

Constructor Description

ConcurrentTokenizedPriorityQueue()

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.

ConcurrentTokenizedPriorityQueue(initialCapacity)

Full Usage: ConcurrentTokenizedPriorityQueue(initialCapacity)

Parameters:
    initialCapacity : 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.

initialCapacity : int

The initial capacity of the queue.

ConcurrentTokenizedPriorityQueue(initialToken, GetNextToken)

Full Usage: ConcurrentTokenizedPriorityQueue(initialToken, GetNextToken)

Parameters:
    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 TryAdd(..) functions to enqueue items.

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.

ConcurrentTokenizedPriorityQueue(capacity, initialToken, GetNextToken)

Full Usage: ConcurrentTokenizedPriorityQueue(capacity, initialToken, GetNextToken)

Parameters:
    capacity : 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.

capacity : 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.

ArgumentOutOfRangeException

Instance members

Instance member Description

this.AddOrUpdate

Full Usage: this.AddOrUpdate

Parameters:
    token : '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.

token : '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.

InvalidOperationException This queue is generating tokens by itself. Use Enqueue(key, value) instead!

this.AddOrUpdate

Full Usage: this.AddOrUpdate

Parameters:
    token : '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.

token : '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.

InvalidOperationException This queue is generating tokens by itself. Use Enqueue(key, value) instead!

this.Clear

Full Usage: this.Clear

Removes all elements from this queue, resulting in an empty queue.

this.ContainsToken

Full Usage: this.ContainsToken

Parameters:
    token : '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.

token : 'TToken

The token.

Returns: bool

True if the provided token exists in the queue; otherwise false.

this.Count

Full Usage: this.Count

Returns: int

Gets the number of elements in the priority queue.

Returns: int

this.Dequeue

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.

Returns: 'TKey * 'TValue

The key/value pair with minimum key value.

InvalidOperationException Queue is empty.

this.Enqueue

Full Usage: this.Enqueue

Parameters:
    key : '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.

key : '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.

InvalidOperationException This queue is unable to generate tokens by itself. You have to construct the priority queue using a token generating function.

this.EnqueueOrUpdate

Full Usage: this.EnqueueOrUpdate

Parameters:
    key : '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.

key : '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.

InvalidOperationException This queue is generating tokens by itself. Use Enqueue(key, value) instead!

this.EnqueueOrUpdate

Full Usage: this.EnqueueOrUpdate

Parameters:
    addValue : 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.

addValue : 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.

InvalidOperationException This queue is generating tokens by itself. Use Enqueue(key, value) instead!

this.IsEmpty

Full Usage: this.IsEmpty

Returns: bool

Gets a value indicating whether the priority queue is empty.

Returns: bool

this.TryAdd

Full Usage: this.TryAdd

Parameters:
    token : '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.

token : '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.

InvalidOperationException This queue is generating tokens by itself. Use Enqueue(key, value) instead!

this.TryDecreaseKey

Full Usage: this.TryDecreaseKey

Parameters:
    token : '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.

token : '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.

InvalidOperationException The new key was equal to or greater than the existing one.

this.TryDequeue

Full Usage: this.TryDequeue

Parameters:
    key : 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.

key : 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.

this.TryGet

Full Usage: this.TryGet

Parameters:
    token : '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.

token : '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.

this.TryGet

Full Usage: this.TryGet

Parameters:
    token : '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.

token : '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.

this.TryIncreaseKey

Full Usage: this.TryIncreaseKey

Parameters:
    token : '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.

token : '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.

InvalidOperationException The new key was equal to or less than the existing one.

this.TryPeek

Full Usage: this.TryPeek

Parameters:
    key : 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.

key : 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.

this.TryPeek

Full Usage: this.TryPeek

Parameters:
    key : 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.

key : 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.

this.TryPeek

Full Usage: this.TryPeek

Parameters:
    key : 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.

key : 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.

this.TryPeekKey

Full Usage: this.TryPeekKey

Parameters:
    key : byref<'TKey>

Returns: bool

key : byref<'TKey>
Returns: bool

this.TryRemove

Full Usage: this.TryRemove

Parameters:
    token : '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).

token : '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.

this.TryRemove

Full Usage: this.TryRemove

Parameters:
    token : '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).

token : '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.

this.TryRemove

Full Usage: this.TryRemove

Parameters:
    token : '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).

token : '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.

this.TryUpdateKey

Full Usage: this.TryUpdateKey

Parameters:
    token : '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.

token : '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.