|
| static< K, V > Map< K, V > | compute (Map< K, V > map, K k, BiFunction< K, V, V > computation) |
| | Returns a map that is identical to the original map, except the value for key k is transformed using the given function.
|
| static< T > Set< T > | copy (Set< T > set) |
| | Returns a copy of the set.
|
| static< T > Set< T > | immutableSetOf (T first, T... rest) |
| | Returns an immutable Set that contains all argument values.
|
| static< T > Set< T > | minus (Set< T > set, T eltToRemove) |
| | Returns a set that contains the elements of the given set minus one element.
|
| static< K, V > Map< K, V > | plus (Map< K, V > map, K k, V v) |
| static< T > Set< T > | plus (Set< T > set, T t) |
| | Returns a set which contains the elements of the given set plus the given element.
|
| static< K, V > void | removeFromValues (Map< K, Set< V > > map, V valueToRemove) |
| | Remove the given value from all the sets that are values in the given map.
|
Utilities to manipulate collections.
Most of these methods are using specialized collection implementations (possibly unmodifiable) for small collection sizes. No guarantee is made on the mutability of the collections returned from these functions, meaning, callers should always assume they are unmodifiable. Functions that take a collection parameter as input to produce a new one with a transformation require the input collection to have been obtained from one of the utility functions of this class in the first place.
| static< K, V > void org.lflang.util.CollectionUtil.removeFromValues |
( |
Map< K, Set< V > > | map, |
|
|
V | valueToRemove ) |
|
static |
Remove the given value from all the sets that are values in the given map.
Use this if the values of the map (the sets) were build with plus.
In org.lflang.graph.DirectedGraph, this is used to properly remove nodes from a graph. There, we use maps to represent edges, where a value in a map is a set of nodes adjacent to the key for that value. Hence, when a node is removed, it needs to be removed not just as a key, but it also needs to be removed from the neighbors sets of any other keys that may contain it.
- Parameters
-
| map | A modifiable map |
| valueToRemove | Value to remove |