- VersionHashMap <ConflictV, K, V>
- Empty
- this []
- IsEmpty
- Count
- Length
- SwapKey (K key, Func<Version<string, K, V>, Version<string, K, V>> swap)
- Update (Version<string, K, V> version)
- RemoveOlderThan (DateTime cutoff)
- RemoveOlderThan (long timeStamp)
- RemoveDeletedItemsOlderThan (DateTime cutoff)
- RemoveDeletedItemsOlderThan (long timeStamp)
- Find (K value)
- FindVersion (K value)
- Keys
- Values
- ToHashMap ()
- GetEnumerator ()
- ToSeq ()
- ToString ()
- ToFullString (string separator = ", ")
- ToFullArrayString (string separator = ", ")
- AsIterable ()
- IsProperSubsetOf (IEnumerable<(K Key, V Value)> other)
- IsProperSubsetOf (IEnumerable<K> other)
- IsProperSupersetOf (IEnumerable<(K Key, V Value)> other)
- IsProperSupersetOf (IEnumerable<K> other)
- IsSubsetOf (IEnumerable<(K Key, V Value)> other)
- IsSubsetOf (IEnumerable<K> other)
- IsSubsetOf (HashMap<K, V> other)
- IsSupersetOf (IEnumerable<(K Key, V Value)> other)
- IsSupersetOf (IEnumerable<K> rhs)
- Intersect (IEnumerable<K> rhs)
- Overlaps (IEnumerable<(K Key, V Value)> other)
- Overlaps (IEnumerable<K> other)
- Except (IEnumerable<K> rhs)
- Equals (object? obj)
- Equals (VersionHashMap<ConflictV, K, V>? other)
- GetHashCode ()
- Where (Func<long, Option<V>, bool> pred)
- Where (Func<K, long, Option<V>, bool> pred)
- Filter (Func<long, Option<V>, bool> pred)
- Filter (Func<K, long, Option<V>, bool> pred)
- FilterInPlace (Func<long, Option<V>, bool> pred)
- FilterInPlace (Func<K, long, Option<V>, bool> pred)
- ForAll (Func<K, V, bool> pred)
- ForAll (Func<(K Key, V Value), bool> pred)
- ForAll (Func<KeyValuePair<K, V>, bool> pred)
- ForAll (Func<V, bool> pred)
- Exists (Func<K, V, bool> pred)
- Exists (Func<(K Key, V Value), bool> pred)
- Exists (Func<V, bool> pred)
- Iter (Action<K, V> action)
- Iter (Action<V> action)
- Iter (Action<(K Key, V Value)> action)
- Iter (Action<KeyValuePair<K, V>> action)
- Fold <S> (S state, Func<S, K, V, S> folder)
- Fold <S> (S state, Func<S, V, S> folder)
- VersionHashMap <ConflictV, OrdActor, EqK, Actor, K, V>
- Empty
- this []
- IsEmpty
- Count
- Length
- SwapKey (K key, Func<Version<Actor, K, V>, Version<Actor, K, V>> swap)
- Update (Version<Actor, K, V> nversion)
- RemoveOlderThan (DateTime cutoff)
- RemoveOlderThan (long timeStamp)
- RemoveDeletedItemsOlderThan (DateTime cutoff)
- RemoveDeletedItemsOlderThan (long timeStamp)
- Find (K value)
- FindVersion (K key)
- Keys
- Values
- ToHashMap ()
- GetEnumerator ()
- ToSeq ()
- ToString ()
- ToFullString (string separator = ", ")
- ToFullArrayString (string separator = ", ")
- AsIterable ()
- IsProperSubsetOf (IEnumerable<(K Key, V Value)> other)
- IsProperSubsetOf (IEnumerable<K> other)
- IsProperSupersetOf (IEnumerable<(K Key, V Value)> other)
- IsProperSupersetOf (IEnumerable<K> other)
- IsSubsetOf (IEnumerable<(K Key, V Value)> other)
- IsSubsetOf (IEnumerable<K> other)
- IsSubsetOf (HashMap<K, V> other)
- IsSupersetOf (IEnumerable<(K Key, V Value)> other)
- IsSupersetOf (IEnumerable<K> rhs)
- Intersect (IEnumerable<K> rhs)
- Overlaps (IEnumerable<(K Key, V Value)> other)
- Overlaps (IEnumerable<K> other)
- Except (IEnumerable<K> rhs)
- Equals (object? obj)
- Equals (VersionHashMap<ConflictV, OrdActor, EqK, Actor, K, V>? other)
- GetHashCode ()
- Where (Func<long, Option<V>, bool> pred)
- Where (Func<K, long, Option<V>, bool> pred)
- Filter (Func<long, Option<V>, bool> pred)
- Filter (Func<K, long, Option<V>, bool> pred)
- FilterInPlace (Func<long, Option<V>, bool> pred)
- FilterInPlace (Func<K, long, Option<V>, bool> pred)
- ForAll (Func<K, V, bool> pred)
- ForAll (Func<(K Key, V Value), bool> pred)
- ForAll (Func<KeyValuePair<K, V>, bool> pred)
- ForAll (Func<V, bool> pred)
- Exists (Func<K, V, bool> pred)
- Exists (Func<(K Key, V Value), bool> pred)
- Exists (Func<V, bool> pred)
- Iter (Action<K, V> action)
- Iter (Action<V> action)
- Iter (Action<(K Key, V Value)> action)
- Iter (Action<KeyValuePair<K, V>> action)
- Fold <S> (S state, Func<S, K, V, S> folder)
- Fold <S> (S state, Func<S, V, S> folder)
- VersionHashMap <K, V>
- Empty
- this []
- IsEmpty
- Count
- Length
- SwapKey (K key, Func<Version<string, K, V>, Version<string, K, V>> swap)
- Update (Version<string, K, V> version)
- RemoveOlderThan (DateTime cutoff)
- RemoveOlderThan (long timeStamp)
- RemoveDeletedItemsOlderThan (DateTime cutoff)
- RemoveDeletedItemsOlderThan (long timeStamp)
- Find (K value)
- FindVersion (K value)
- Keys
- Values
- ToHashMap ()
- GetEnumerator ()
- ToSeq ()
- ToString ()
- ToFullString (string separator = ", ")
- ToFullArrayString (string separator = ", ")
- AsIterable ()
- IsProperSubsetOf (IEnumerable<(K Key, V Value)> other)
- IsProperSubsetOf (IEnumerable<K> other)
- IsProperSupersetOf (IEnumerable<(K Key, V Value)> other)
- IsProperSupersetOf (IEnumerable<K> other)
- IsSubsetOf (IEnumerable<(K Key, V Value)> other)
- IsSubsetOf (IEnumerable<K> other)
- IsSubsetOf (HashMap<K, V> other)
- IsSupersetOf (IEnumerable<(K Key, V Value)> other)
- IsSupersetOf (IEnumerable<K> rhs)
- Intersect (IEnumerable<K> rhs)
- Overlaps (IEnumerable<(K Key, V Value)> other)
- Overlaps (IEnumerable<K> other)
- Except (IEnumerable<K> rhs)
- Equals (object? obj)
- Equals (VersionHashMap<K, V>? other)
- GetHashCode ()
- Where (Func<long, Option<V>, bool> pred)
- Where (Func<K, long, Option<V>, bool> pred)
- Filter (Func<long, Option<V>, bool> pred)
- Filter (Func<K, long, Option<V>, bool> pred)
- FilterInPlace (Func<long, Option<V>, bool> pred)
- FilterInPlace (Func<K, long, Option<V>, bool> pred)
- ForAll (Func<K, V, bool> pred)
- ForAll (Func<(K Key, V Value), bool> pred)
- ForAll (Func<KeyValuePair<K, V>, bool> pred)
- ForAll (Func<V, bool> pred)
- Exists (Func<K, V, bool> pred)
- Exists (Func<(K Key, V Value), bool> pred)
- Exists (Func<V, bool> pred)
- Iter (Action<K, V> action)
- Iter (Action<V> action)
- Iter (Action<(K Key, V Value)> action)
- Iter (Action<KeyValuePair<K, V>> action)
- Fold <S> (S state, Func<S, K, V, S> folder)
- Fold <S> (S state, Func<S, V, S> folder)
class VersionHashMap <ConflictV, K, V> Source #
Versioned hash-map. Each value has a vector-clock attached to it which understands the causality of updates from multiple actors. Actors are just unique keys that represent individual contributors. They could be client connections, nodes in a network, users, or whatever is appropriate to discriminate between commits.
Deleted items are not removed from the hash-map, they are merely marked as deleted. This allows conflicts between writes and deletes to be resolved.
Run RemoveDeletedItemsOlderThan
to clean up items that have been deleted and are now just hanging around. Use
a big enough delay that it won't conflict with other commits (this could be seconds, minutes, or longer:
depending on the expected latency of writes to the hash-map).
This is a mutable collection with atomic, thread-safe, updates.
method Unit SwapKey (K key, Func<Version<string, K, V>, Version<string, K, V>> swap) Source #
Atomically swap a key in the map. Allows for multiple operations on the hash-map in an entirely transactional and atomic way.
Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts
param | swap | Swap function, maps the current state of the value associated with the key to a new state |
method Unit Update (Version<string, K, V> version) Source #
Atomically updates a new item in the map. If the key already exists, then the vector clocks, within the version vector, are compared to ascertain if the proposed version was caused-by, causes, or conflicts with the current version:
* If the proposed version was caused-by the current version, then it is ignored.
* If the proposed version causes the current version, then it is accepted and updated as the latest version
* If the proposed version is in conflict with the current version, then values from both versions are
passed to ConflictV.Append(v1, v2) for value resolution, and the pairwise-maximum of the two vector-clocks
is taken to be the new 'time.
param | version | Version to update |
method Unit RemoveOlderThan (DateTime cutoff) Source #
Remove items that are older than the specified time-stamp
param | cutoff | Cut off time-stamp |
method Unit RemoveOlderThan (long timeStamp) Source #
Remove items that are older than the specified time-stamp
param | timeStamp | Cut off time-stamp |
method Unit RemoveDeletedItemsOlderThan (DateTime cutoff) Source #
Remove deleted items that are older than the specified time-stamp
param | cutoff | Cut off time-stamp |
method Unit RemoveDeletedItemsOlderThan (long timeStamp) Source #
Remove deleted items that are older than the specified time-stamp
param | timeStamp | Cut off time-stamp |
method Option<V> Find (K value) Source #
Retrieve a value from the map by key
param | key | Key to find |
returns | Found value |
method Version<string, K, V> FindVersion (K value) Source #
Retrieve a value from the map by key
param | key | Key to find |
returns | Found value |
method IEnumerator<(K Key, V Value)> GetEnumerator () Source #
GetEnumerator - IEnumerable interface
method string ToString () Source #
Format the collection as [(key: value), (key: value), (key: value), ...]
The ellipsis is used for collections over 50 items
To get a formatted string with all the items, use ToFullString
or ToFullArrayString
.
method string ToFullString (string separator = ", ") Source #
Format the collection as (key: value), (key: value), (key: value), ...
method string ToFullArrayString (string separator = ", ") Source #
Format the collection as [(key: value), (key: value), (key: value), ...]
method Iterable<(K Key, V Value)> AsIterable () Source #
method bool IsProperSubsetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a proper subset of this set
returns | True if 'other' is a proper subset of this set |
method bool IsProperSubsetOf (IEnumerable<K> other) Source #
Returns True if 'other' is a proper subset of this set
returns | True if 'other' is a proper subset of this set |
method bool IsProperSupersetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a proper superset of this set
returns | True if 'other' is a proper superset of this set |
method bool IsProperSupersetOf (IEnumerable<K> other) Source #
Returns True if 'other' is a proper superset of this set
returns | True if 'other' is a proper superset of this set |
method bool IsSubsetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSubsetOf (IEnumerable<K> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSubsetOf (HashMap<K, V> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSupersetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSupersetOf (IEnumerable<K> rhs) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method Unit Intersect (IEnumerable<K> rhs) Source #
Returns the elements that are in both this and other
method bool Overlaps (IEnumerable<(K Key, V Value)> other) Source #
Returns True if other overlaps this set
method Unit Except (IEnumerable<K> rhs) Source #
Returns this - rhs. Only the items in this that are not in rhs will be returned.
method bool Equals (object? obj) Source #
Equality of keys and values with EqDefault<V>
used for values
method bool Equals (VersionHashMap<ConflictV, K, V>? other) Source #
Equality of keys and values with EqDefault<V>
used for values
method int GetHashCode () Source #
method VersionHashMap<ConflictV, K, V> Where (Func<long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method VersionHashMap<ConflictV, K, V> Where (Func<K, long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method VersionHashMap<ConflictV, K, V> Filter (Func<long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method VersionHashMap<ConflictV, K, V> Filter (Func<K, long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method Unit FilterInPlace (Func<long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method Unit FilterInPlace (Func<K, long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method bool ForAll (Func<K, V, bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool ForAll (Func<(K Key, V Value), bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool ForAll (Func<KeyValuePair<K, V>, bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool ForAll (Func<V, bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool Exists (Func<K, V, bool> pred) Source #
Return true if any items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool Exists (Func<(K Key, V Value), bool> pred) Source #
Return true if any items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool Exists (Func<V, bool> pred) Source #
Return true if any items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method Unit Iter (Action<K, V> action) Source #
Atomically iterate through all key/value pairs in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
method Unit Iter (Action<V> action) Source #
Atomically iterate through all values in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
method Unit Iter (Action<(K Key, V Value)> action) Source #
Atomically iterate through all key/value pairs (as tuples) in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
method Unit Iter (Action<KeyValuePair<K, V>> action) Source #
Atomically iterate through all key/value pairs in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
class VersionHashMap <ConflictV, OrdActor, EqK, Actor, K, V> Source #
Versioned hash-map. Each value has a vector-clock attached to it which understands the causality of updates from multiple actors. Actors are just unique keys that represent individual contributors. They could be client connections, nodes in a network, users, or whatever is appropriate to discriminate between commits.
Deleted items are not removed from the hash-map, they are merely marked as deleted. This allows conflicts between writes and deletes to be resolved.
Run RemoveDeletedItemsOlderThan
to clean up items that have been deleted and are now just hanging around. Use
a big enough delay that it won't conflict with other commits (this could be seconds, minutes, or longer:
depending on the expected latency of writes to the hash-map).
This is a mutable collection with atomic, thread-safe, updates.
method Unit SwapKey (K key, Func<Version<Actor, K, V>, Version<Actor, K, V>> swap) Source #
Atomically swap a key in the map. Allows for multiple operations on the hash-map in an entirely transactional and atomic way.
Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts
param | swap | Swap function, maps the current state of the value associated with the key to a new state |
method Unit Update (Version<Actor, K, V> nversion) Source #
Atomically updates a new item in the map. If the key already exists, then the vector clocks, within the version vector, are compared to ascertain if the proposed version was caused-by, causes, or conflicts with the current version:
* If the proposed version was caused-by the current version, then it is ignored.
* If the proposed version causes the current version, then it is accepted and updated as the latest version
* If the proposed version is in conflict with the current version, then values from both versions are
passed to ConflictV.Append(v1, v2) for value resolution, and the pairwise-maximum of the two vector-clocks
is taken to be the new 'time.
param | version | Version to update |
method Unit RemoveOlderThan (DateTime cutoff) Source #
Remove items that are older than the specified time-stamp
param | cutoff | Cut off time-stamp |
method Unit RemoveOlderThan (long timeStamp) Source #
Remove items that are older than the specified time-stamp
param | timeStamp | Cut off time-stamp |
method Unit RemoveDeletedItemsOlderThan (DateTime cutoff) Source #
Remove deleted items that are older than the specified time-stamp
param | cutoff | Cut off time-stamp |
method Unit RemoveDeletedItemsOlderThan (long timeStamp) Source #
Remove deleted items that are older than the specified time-stamp
param | timeStamp | Cut off time-stamp |
method Option<V> Find (K value) Source #
Retrieve a value from the map by key
param | key | Key to find |
returns | Found value |
method Version<Actor, K, V> FindVersion (K key) Source #
Retrieve a value from the map by key
param | key | Key to find |
returns | Found value |
method IEnumerator<(K Key, V Value)> GetEnumerator () Source #
GetEnumerator - IEnumerable interface
method string ToString () Source #
Format the collection as [(key: value), (key: value), (key: value), ...]
The ellipsis is used for collections over 50 items
To get a formatted string with all the items, use ToFullString
or ToFullArrayString
.
method string ToFullString (string separator = ", ") Source #
Format the collection as (key: value), (key: value), (key: value), ...
method string ToFullArrayString (string separator = ", ") Source #
Format the collection as [(key: value), (key: value), (key: value), ...]
method Iterable<(K Key, V Value)> AsIterable () Source #
method bool IsProperSubsetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a proper subset of this set
returns | True if 'other' is a proper subset of this set |
method bool IsProperSubsetOf (IEnumerable<K> other) Source #
Returns True if 'other' is a proper subset of this set
returns | True if 'other' is a proper subset of this set |
method bool IsProperSupersetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a proper superset of this set
returns | True if 'other' is a proper superset of this set |
method bool IsProperSupersetOf (IEnumerable<K> other) Source #
Returns True if 'other' is a proper superset of this set
returns | True if 'other' is a proper superset of this set |
method bool IsSubsetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSubsetOf (IEnumerable<K> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSubsetOf (HashMap<K, V> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSupersetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSupersetOf (IEnumerable<K> rhs) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method Unit Intersect (IEnumerable<K> rhs) Source #
Returns the elements that are in both this and other
method bool Overlaps (IEnumerable<(K Key, V Value)> other) Source #
Returns True if other overlaps this set
method Unit Except (IEnumerable<K> rhs) Source #
Returns this - rhs. Only the items in this that are not in rhs will be returned.
method bool Equals (object? obj) Source #
Equality of keys and values with EqDefault<V>
used for values
method bool Equals (VersionHashMap<ConflictV, OrdActor, EqK, Actor, K, V>? other) Source #
Equality of keys and values with EqDefault<V>
used for values
method int GetHashCode () Source #
method VersionHashMap<ConflictV, OrdActor, EqK, Actor, K, V> Where (Func<long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method VersionHashMap<ConflictV, OrdActor, EqK, Actor, K, V> Where (Func<K, long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method VersionHashMap<ConflictV, OrdActor, EqK, Actor, K, V> Filter (Func<long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method VersionHashMap<ConflictV, OrdActor, EqK, Actor, K, V> Filter (Func<K, long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method Unit FilterInPlace (Func<long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method Unit FilterInPlace (Func<K, long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method bool ForAll (Func<K, V, bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool ForAll (Func<(K Key, V Value), bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool ForAll (Func<KeyValuePair<K, V>, bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool ForAll (Func<V, bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool Exists (Func<K, V, bool> pred) Source #
Return true if any items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool Exists (Func<(K Key, V Value), bool> pred) Source #
Return true if any items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool Exists (Func<V, bool> pred) Source #
Return true if any items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method Unit Iter (Action<K, V> action) Source #
Atomically iterate through all key/value pairs in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
method Unit Iter (Action<V> action) Source #
Atomically iterate through all values in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
method Unit Iter (Action<(K Key, V Value)> action) Source #
Atomically iterate through all key/value pairs (as tuples) in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
method Unit Iter (Action<KeyValuePair<K, V>> action) Source #
Atomically iterate through all key/value pairs in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
class VersionHashMap <K, V> Source #
Versioned hash-map. Each value has a vector-clock attached to it which understands the causality of updates from multiple actors. Actors are just unique keys that represent individual contributors. They could be client connections, nodes in a network, users, or whatever is appropriate to discriminate between commits.
Deleted items are not removed from the hash-map, they are merely marked as deleted. This allows conflicts between writes and deletes to be resolved.
Run RemoveDeletedItemsOlderThan
to clean up items that have been deleted and are now just hanging around. Use
a big enough delay that it won't conflict with other commits (this could be seconds, minutes, or longer:
depending on the expected latency of writes to the hash-map).
This is a mutable collection with atomic, thread-safe, updates.
method Unit SwapKey (K key, Func<Version<string, K, V>, Version<string, K, V>> swap) Source #
Atomically swap a key in the map. Allows for multiple operations on the hash-map in an entirely transactional and atomic way.
Any functions passed as arguments may be run multiple times if there are multiple threads competing to update this data structure. Therefore the functions must spend as little time performing the injected behaviours as possible to avoid repeated attempts
param | swap | Swap function, maps the current state of the value associated with the key to a new state |
method Unit Update (Version<string, K, V> version) Source #
Atomically updates a new item in the map. If the key already exists, then the vector clocks, within the version vector, are compared to ascertain if the proposed version was caused-by, causes, or conflicts with the current version:
* If the proposed version was caused-by the current version, then it is ignored.
* If the proposed version causes the current version, then it is accepted and updated as the latest version
* If the proposed version is in conflict with the current version, then values from both versions are
passed to ConflictV.Append(v1, v2) for value resolution, and the pairwise-maximum of the two vector-clocks
is taken to be the new 'time.
param | version | Version to update |
method Unit RemoveOlderThan (DateTime cutoff) Source #
Remove items that are older than the specified time-stamp
param | cutoff | Cut off time-stamp |
method Unit RemoveOlderThan (long timeStamp) Source #
Remove items that are older than the specified time-stamp
param | timeStamp | Cut off time-stamp |
method Unit RemoveDeletedItemsOlderThan (DateTime cutoff) Source #
Remove deleted items that are older than the specified time-stamp
param | cutoff | Cut off time-stamp |
method Unit RemoveDeletedItemsOlderThan (long timeStamp) Source #
Remove deleted items that are older than the specified time-stamp
param | timeStamp | Cut off time-stamp |
method Option<V> Find (K value) Source #
Retrieve a value from the map by key
param | key | Key to find |
returns | Found value |
method Version<string, K, V> FindVersion (K value) Source #
Retrieve a value from the map by key
param | key | Key to find |
returns | Found value |
method IEnumerator<(K Key, V Value)> GetEnumerator () Source #
GetEnumerator - IEnumerable interface
method string ToString () Source #
Format the collection as [(key: value), (key: value), (key: value), ...]
The ellipsis is used for collections over 50 items
To get a formatted string with all the items, use ToFullString
or ToFullArrayString
.
method string ToFullString (string separator = ", ") Source #
Format the collection as (key: value), (key: value), (key: value), ...
method string ToFullArrayString (string separator = ", ") Source #
Format the collection as [(key: value), (key: value), (key: value), ...]
method Iterable<(K Key, V Value)> AsIterable () Source #
method bool IsProperSubsetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a proper subset of this set
returns | True if 'other' is a proper subset of this set |
method bool IsProperSubsetOf (IEnumerable<K> other) Source #
Returns True if 'other' is a proper subset of this set
returns | True if 'other' is a proper subset of this set |
method bool IsProperSupersetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a proper superset of this set
returns | True if 'other' is a proper superset of this set |
method bool IsProperSupersetOf (IEnumerable<K> other) Source #
Returns True if 'other' is a proper superset of this set
returns | True if 'other' is a proper superset of this set |
method bool IsSubsetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSubsetOf (IEnumerable<K> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSubsetOf (HashMap<K, V> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSupersetOf (IEnumerable<(K Key, V Value)> other) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method bool IsSupersetOf (IEnumerable<K> rhs) Source #
Returns True if 'other' is a superset of this set
returns | True if 'other' is a superset of this set |
method Unit Intersect (IEnumerable<K> rhs) Source #
Returns the elements that are in both this and other
method bool Overlaps (IEnumerable<(K Key, V Value)> other) Source #
Returns True if other overlaps this set
method Unit Except (IEnumerable<K> rhs) Source #
Returns this - rhs. Only the items in this that are not in rhs will be returned.
method bool Equals (object? obj) Source #
Equality of keys and values with EqDefault<V>
used for values
method bool Equals (VersionHashMap<K, V>? other) Source #
Equality of keys and values with EqDefault<V>
used for values
method int GetHashCode () Source #
method VersionHashMap<K, V> Where (Func<long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method VersionHashMap<K, V> Where (Func<K, long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method VersionHashMap<K, V> Filter (Func<long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method VersionHashMap<K, V> Filter (Func<K, long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method Unit FilterInPlace (Func<long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method Unit FilterInPlace (Func<K, long, Option<V>, bool> pred) Source #
Atomically filter out items that return false when a predicate is applied
param | pred | Predicate |
returns | New map with items filtered |
method bool ForAll (Func<K, V, bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool ForAll (Func<(K Key, V Value), bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool ForAll (Func<KeyValuePair<K, V>, bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool ForAll (Func<V, bool> pred) Source #
Return true if all items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool Exists (Func<K, V, bool> pred) Source #
Return true if any items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool Exists (Func<(K Key, V Value), bool> pred) Source #
Return true if any items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method bool Exists (Func<V, bool> pred) Source #
Return true if any items in the map return true when the predicate is applied
param | pred | Predicate |
returns | True if all items in the map return true when the predicate is applied |
method Unit Iter (Action<K, V> action) Source #
Atomically iterate through all key/value pairs in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
method Unit Iter (Action<V> action) Source #
Atomically iterate through all values in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
method Unit Iter (Action<(K Key, V Value)> action) Source #
Atomically iterate through all key/value pairs (as tuples) in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |
method Unit Iter (Action<KeyValuePair<K, V>> action) Source #
Atomically iterate through all key/value pairs in the map (in order) and execute an action on each
param | action | Action to execute |
returns | Unit |