A path map with wild card matching.
Synopsis
WildMap is a multimap that maps keys to multiple values. When queried, the values are returned as an array of values for the key.
Keys used for lookup can be applied directly using get
to get an array of
values that exactly match that key.
Keys used for lookup can also be applied as wildcard matches using gather
to
get an array of values that are found along the path described by the key.
var assert = var WildMap = var map = mapmapmapmapmapmap assert assert assert map assert
This structure is useful for messaging. For a practical application see Signal.
map = new WildMap
Create a new empty map.
map.add(path, value)
Add a value to the set of values at the given path.
map.get(path)
Get the set of values at the given path.
map.match(pattern)
Get a collection of all the values along the given path.
map.remove(path, value)
Remove the value if it is contained by the set at the given path.