moonbitstack/moonstl/map does not have a README file

    FlatMultiSet

    type FlatMultiSet[K] = FlatMultiMap[K, Unit]

    A flat multiset keeps repeats in sorted order and counts them.

    MultiSet

    type MultiSet[K] = MultiMap[K, Unit]

    A multiset is a multimap whose values carry no information.

    SortedMultiSet

    type SortedMultiSet[K] = SortedMultiMap[K, Unit]

    A sorted multiset is a sorted multimap whose values carry no information.

    BiMap

    pub struct BiMap[K, V] {
    forward : IndexMap[K, V]
    backward : IndexMap[V, K]
    }

    A two-way map: the pair k -> v can be read from either side, and neither a key nor a value can appear twice. set keeps the mapping total by dropping whatever the new pair collides with, and hands it back.

    test {
    let bimap : @map.BiMap[Int32, String] = @map.BiMap::new()
    let _ = bimap.set(1, "a")
    let _ = bimap.set(2, "b")
    @test.assert_eq(bimap.get_key("b"), Some(2))
    @test.assert_eq(bimap.set(1, "b"), Some((1, "a")))
    @test.assert_eq(bimap.get(1), Some("b"))
    @test.assert_eq(bimap.get(2), None)
    }
    impl Eq for BiMap[K, V]
    impl Show for BiMap[K, V]

    BiMap::clear

    fn[K, V] BiMap::clear(self : BiMap[K, V]) -> Unit

    BiMap::contains_key

    fn[K : Hash + Eq, V] BiMap::contains_key(self : BiMap[K, V], key : K) -> Bool

    BiMap::contains_value

    fn[K, V : Hash + Eq] BiMap::contains_value(self : BiMap[K, V], value : V) -> Bool

    BiMap::copy

    fn[K, V] BiMap::copy(self : BiMap[K, V]) -> BiMap[K, V]

    BiMap::equal

    fn[K : Eq, V : Eq] BiMap::equal(self : BiMap[K, V], other : BiMap[K, V]) -> Bool

    BiMap::get

    fn[K : Hash + Eq, V] BiMap::get(self : BiMap[K, V], key : K) -> V?

    BiMap::get_key

    fn[K, V : Hash + Eq] BiMap::get_key(self : BiMap[K, V], value : V) -> K?

    The key a value belongs to, which is the reverse of get.

    BiMap::is_empty

    fn[K, V] BiMap::is_empty(self : BiMap[K, V]) -> Bool

    BiMap::iter

    fn[K, V] BiMap::iter(self : BiMap[K, V]) -> Iter[(K, V)]

    BiMap::keys

    fn[K, V] BiMap::keys(self : BiMap[K, V]) -> Iter[K]

    BiMap::length

    fn[K, V] BiMap::length(self : BiMap[K, V]) -> Int

    BiMap::new

    fn[K, V] BiMap::new(capacity? : Int, hash_seed? : Int) -> BiMap[K, V]

    BiMap::not_equal

    fn[K : Eq, V : Eq] BiMap::not_equal(x : BiMap[K, V], y : BiMap[K, V]) -> Bool

    BiMap::output

    fn[K : Show, V : Show] BiMap::output(self : BiMap[K, V], logger : &Logger) -> Unit

    BiMap::remove_key

    fn[K : Hash + Eq, V : Hash + Eq] BiMap::remove_key(self : BiMap[K, V], key : K) -> (K, V)?

    BiMap::remove_value

    fn[K : Hash + Eq, V : Hash + Eq] BiMap::remove_value(self : BiMap[K, V], value : V) -> (K, V)?

    BiMap::set

    fn[K : Hash + Eq, V : Hash + Eq] BiMap::set(self : BiMap[K, V], key : K, value : V) -> (K, V)?

    Stores the pair, dropping the pair the key belonged to and the pair the value belonged to, and returns one of the dropped pairs — the one the key displaced when there is one, otherwise the one the value displaced.

    BiMap::set_new

    fn[K : Hash + Eq, V : Hash + Eq] BiMap::set_new(self : BiMap[K, V], key : K, value : V) -> Unit raise
    Refused

    Stores the pair only when neither side is taken, and refuses otherwise.

    BiMap::to_string

    fn[K : Show, V : Show] BiMap::to_string(self : BiMap[K, V]) -> String

    BiMap::values

    fn[K, V] BiMap::values(self : BiMap[K, V]) -> Iter[V]

    ChainMap

    pub struct ChainMap[K, V] {
    chain : Array[Map[K, V]]
    }

    A stack of maps read as one: a lookup falls through the stack from the front, and a write always lands in the front map. That is what a layered configuration needs — a child scope that sees its parent's settings but shadows them without touching them.

    test {
    let base : Map[String, Int32] = Map([])
    base.set("a", 1)
    let chain : @map.ChainMap[String, Int32] = @map.ChainMap::new([base])
    @test.assert_eq(chain.get("a"), Some(1))
    let child = chain.new_child()
    child.set("a", 2)
    @test.assert_eq(child.get("a"), Some(2))
    @test.assert_eq(chain.get("a"), Some(1))
    }

    ChainMap::contains

    fn[K : Hash + Eq, V] ChainMap::contains(self : ChainMap[K, V], key : K) -> Bool

    ChainMap::copy

    fn[K, V] ChainMap::copy(self : ChainMap[K, V]) -> ChainMap[K, V]

    ChainMap::flatten

    fn[K : Hash + Eq, V] ChainMap::flatten(self : ChainMap[K, V]) -> Map[K, V]

    Copies the chain into one map, which is what a child does when it has to stop following its parent.

    ChainMap::get

    fn[K : Hash + Eq, V] ChainMap::get(self : ChainMap[K, V], key : K) -> V?

    ChainMap::iter

    fn[K : Hash + Eq, V] ChainMap::iter(self : ChainMap[K, V]) -> Iter[(K, V)]

    Every pair the chain answers for: the first map that holds a key decides its value.

    ChainMap::length

    fn[K : Hash + Eq, V] ChainMap::length(self : ChainMap[K, V]) -> Int

    The number of distinct keys the chain answers for.

    ChainMap::maps

    fn[K, V] ChainMap::maps(self : ChainMap[K, V]) -> Array[Map[K, V]]

    The maps of the chain, front first.

    ChainMap::new

    fn[K, V] ChainMap::new(maps : Array[Map[K, V]]) -> ChainMap[K, V]

    Builds a chain over maps, the first of which is written to.

    ChainMap::new_child

    fn[K : Hash + Eq, V] ChainMap::new_child(self : ChainMap[K, V]) -> ChainMap[K, V]

    Puts a fresh empty map in front, which is how a narrower scope is opened.

    ChainMap::parent

    fn[K, V] ChainMap::parent(self : ChainMap[K, V]) -> ChainMap[K, V]?

    The chain without its front map, or None when only one is left.

    ChainMap::remove

    fn[K : Hash + Eq, V] ChainMap::remove(self : ChainMap[K, V], key : K) -> Unit

    Removes key from every map in the chain, so a shadowed value does not reappear once the front one is dropped.

    ChainMap::set

    fn[K : Hash + Eq, V] ChainMap::set(self : ChainMap[K, V], key : K, value : V) -> Unit

    Writes into the front map, which is the only map a chain ever changes.

    Counter

    pub struct Counter[K] {
    map : IndexMap[K, Int]
    total_count : Int64
    }

    A multiset of counts: each key carries how many times it was seen, and a key whose count reaches zero leaves the counter so that iteration only ever sees keys that are present.

    test {
    let counter : @map.Counter[String] = @map.Counter::new()
    @test.assert_eq(counter.incr("a"), 1)
    @test.assert_eq(counter.incr_by("a", 2), 3)
    @test.assert_eq(counter.decr("a"), 2)
    @test.assert_eq(counter.total(), 2L)
    }
    impl Eq for Counter[K]
    impl Show for Counter[K]

    Counter::add

    fn[K : Hash + Eq] Counter::add(self : Counter[K], other : Counter[K]) -> Counter[K]

    The sum of two counters, as a new one. The keys keep the order of self, and keys only other has follow.

    Counter::clear

    fn[K] Counter::clear(self : Counter[K]) -> Unit

    Counter::copy

    fn[K] Counter::copy(self : Counter[K]) -> Counter[K]

    Counter::decr

    fn[K : Hash + Eq] Counter::decr(self : Counter[K], key : K) -> Int

    Counter::decr_by

    fn[K : Hash + Eq] Counter::decr_by(self : Counter[K], key : K, amount : Int) -> Int

    Counter::elements

    fn[K] Counter::elements(self : Counter[K]) -> Iter[K]

    Every key repeated as many times as it was counted.

    Counter::equal

    fn[K : Eq] Counter::equal(self : Counter[K], other : Counter[K]) -> Bool

    Counter::get

    fn[K : Hash + Eq] Counter::get(self : Counter[K], key : K) -> Int

    The count of key, zero when it has none.

    Counter::incr

    fn[K : Hash + Eq] Counter::incr(self : Counter[K], key : K) -> Int

    Adds one and returns the new count.

    Counter::incr_by

    fn[K : Hash + Eq] Counter::incr_by(self : Counter[K], key : K, amount : Int) -> Int

    Adds amount, which may be negative, and returns the new count. A count that reaches zero or below removes the key.

    Counter::is_empty

    fn[K] Counter::is_empty(self : Counter[K]) -> Bool

    Counter::iter

    fn[K] Counter::iter(self : Counter[K]) -> Iter[(K, Int)]

    Counter::keys

    fn[K] Counter::keys(self : Counter[K]) -> Iter[K]

    Counter::length

    fn[K] Counter::length(self : Counter[K]) -> Int

    Counter::most_common

    fn[K] Counter::most_common(self : Counter[K], n~ : Int) -> Array[(K, Int)]

    The n keys with the largest counts, ties in insertion order. n below zero means every key.

    Counter::new

    fn[K] Counter::new(capacity? : Int, hash_seed? : Int) -> Counter[K]

    Counter::not_equal

    fn[K : Eq] Counter::not_equal(x : Counter[K], y : Counter[K]) -> Bool

    Counter::output

    fn[K : Show] Counter::output(self : Counter[K], logger : &Logger) -> Unit

    Counter::retain

    fn[K : Hash + Eq] Counter::retain(self : Counter[K], f : (K, Int) -> Bool) -> Unit

    Counter::subtract_in_place

    fn[K : Hash + Eq] Counter::subtract_in_place(self : Counter[K], other : Counter[K]) -> Unit

    Subtracts other from this counter in place, dropping keys that reach zero.

    Counter::to_array

    fn[K] Counter::to_array(self : Counter[K]) -> Array[(K, Int)]

    Counter::to_string

    fn[K : Show] Counter::to_string(self : Counter[K]) -> String

    Counter::total

    fn[K] Counter::total(self : Counter[K]) -> Int64

    The sum of every count.

    DefaultMap

    pub struct DefaultMap[K, V] {
    map : IndexMap[K, V]
    factory : (K) -> V
    }

    A map that answers a lookup with a value it makes up on the spot: the factory is called with the key, so a reader never has to write the check-then-insert pair by hand.

    test {
    let map : @map.DefaultMap[String, Int32] = @map.DefaultMap::new(factory=key => {
    key.length()
    })
    @test.assert_eq(map.get_or_init("abc"), 3)
    @test.assert_eq(map.length(), 1)
    @test.assert_eq(map.get("abc"), Some(3))
    }
    impl Eq for DefaultMap[K, V]
    impl Show for DefaultMap[K, V]

    DefaultMap::clear

    fn[K, V] DefaultMap::clear(self : DefaultMap[K, V]) -> Unit

    DefaultMap::contains

    fn[K : Hash + Eq, V] DefaultMap::contains(self : DefaultMap[K, V], key : K) -> Bool

    DefaultMap::copy

    fn[K, V] DefaultMap::copy(self : DefaultMap[K, V]) -> DefaultMap[K, V]

    DefaultMap::equal

    fn[K : Eq, V : Eq] DefaultMap::equal(self : DefaultMap[K, V], other : DefaultMap[K, V]) -> Bool

    DefaultMap::get

    fn[K : Hash + Eq, V] DefaultMap::get(self : DefaultMap[K, V], key : K) -> V?

    DefaultMap::get_or_init

    fn[K : Hash + Eq, V] DefaultMap::get_or_init(self : DefaultMap[K, V], key : K) -> V

    The value under key, inserting factory(key) when the key is new.

    DefaultMap::is_empty

    fn[K, V] DefaultMap::is_empty(self : DefaultMap[K, V]) -> Bool

    DefaultMap::iter

    fn[K, V] DefaultMap::iter(self : DefaultMap[K, V]) -> Iter[(K, V)]

    DefaultMap::keys

    fn[K, V] DefaultMap::keys(self : DefaultMap[K, V]) -> Iter[K]

    DefaultMap::length

    fn[K, V] DefaultMap::length(self : DefaultMap[K, V]) -> Int

    DefaultMap::new

    fn[K, V] DefaultMap::new(factory~ : (K) -> V, capacity? : Int, hash_seed? : Int) -> DefaultMap[K, V]

    DefaultMap::not_equal

    fn[K : Eq, V : Eq] DefaultMap::not_equal(x : DefaultMap[K, V], y : DefaultMap[K, V]) -> Bool

    DefaultMap::output

    fn[K : Show, V : Show] DefaultMap::output(self : DefaultMap[K, V], logger : &Logger) -> Unit

    DefaultMap::remove

    fn[K : Hash + Eq, V] DefaultMap::remove(self : DefaultMap[K, V], key : K) -> V?

    DefaultMap::set

    fn[K : Hash + Eq, V] DefaultMap::set(self : DefaultMap[K, V], key : K, value : V) -> V?

    DefaultMap::to_string

    fn[K : Show, V : Show] DefaultMap::to_string(self : DefaultMap[K, V]) -> String

    DefaultMap::values

    fn[K, V] DefaultMap::values(self : DefaultMap[K, V]) -> Iter[V]

    FlatMap

    pub struct FlatMap[K, V] {
    keys : Array[K]
    values : Array[V]
    }

    A map held as a sorted array of keys with a parallel array of values: a lookup is a binary search over contiguous memory, which is the shape to reach for when a table is built once and read many times.

    test {
    let map : @map.FlatMap[Int32, String] = @map.FlatMap::new()
    let _ = map.set(2, "b")
    let _ = map.set(1, "a")
    @test.assert_eq(map.keys().to_array(), [1, 2])
    @test.assert_eq(map.get(2), Some("b"))
    @test.assert_eq(map.index_of(3), Err(2))
    }
    impl Eq for FlatMap[K, V]
    impl Show for FlatMap[K, V]

    FlatMap::capacity

    fn[K, V] FlatMap::capacity(self : FlatMap[K, V]) -> Int

    FlatMap::clear

    fn[K, V] FlatMap::clear(self : FlatMap[K, V]) -> Unit

    FlatMap::contains

    fn[K : Compare + Eq, V] FlatMap::contains(self : FlatMap[K, V], key : K) -> Bool

    FlatMap::copy

    fn[K, V] FlatMap::copy(self : FlatMap[K, V]) -> FlatMap[K, V]

    FlatMap::equal

    fn[K : Eq, V : Eq] FlatMap::equal(self : FlatMap[K, V], other : FlatMap[K, V]) -> Bool

    FlatMap::first

    fn[K, V] FlatMap::first(self : FlatMap[K, V]) -> (K, V)?

    FlatMap::from_array

    fn[K : Compare + Eq, V] FlatMap::from_array(entries : ArrayView[(K, V)]) -> FlatMap[K, V]

    Sorts the pairs by key; when a key repeats, the last pair in the array wins.

    FlatMap::get

    fn[K : Compare + Eq, V] FlatMap::get(self : FlatMap[K, V], key : K) -> V?

    FlatMap::get_index

    fn[K, V] FlatMap::get_index(self : FlatMap[K, V], index : Int) -> (K, V)?

    FlatMap::index_of

    fn[K : Compare + Eq, V] FlatMap::index_of(self : FlatMap[K, V], key : K) -> Result[Int, Int]

    Where key is, or where it would be inserted.

    FlatMap::is_empty

    fn[K, V] FlatMap::is_empty(self : FlatMap[K, V]) -> Bool

    FlatMap::iter

    fn[K, V] FlatMap::iter(self : FlatMap[K, V]) -> Iter[(K, V)]

    FlatMap::keys

    fn[K, V] FlatMap::keys(self : FlatMap[K, V]) -> Iter[K]

    FlatMap::last

    fn[K, V] FlatMap::last(self : FlatMap[K, V]) -> (K, V)?

    FlatMap::length

    fn[K, V] FlatMap::length(self : FlatMap[K, V]) -> Int

    FlatMap::new

    fn[K, V] FlatMap::new(capacity? : Int) -> FlatMap[K, V]

    FlatMap::not_equal

    fn[K : Eq, V : Eq] FlatMap::not_equal(x : FlatMap[K, V], y : FlatMap[K, V]) -> Bool

    FlatMap::output

    fn[K : Show, V : Show] FlatMap::output(self : FlatMap[K, V], logger : &Logger) -> Unit

    FlatMap::pop_first

    fn[K, V] FlatMap::pop_first(self : FlatMap[K, V]) -> (K, V)?

    FlatMap::pop_last

    fn[K, V] FlatMap::pop_last(self : FlatMap[K, V]) -> (K, V)?

    FlatMap::range

    fn[K : Compare + Eq, V] FlatMap::range(self : FlatMap[K, V], start~ : K, end~ : K) -> Iter[(K, V)]

    The pairs whose keys fall between start and end, both included.

    FlatMap::remove

    fn[K : Compare + Eq, V] FlatMap::remove(self : FlatMap[K, V], key : K) -> V?

    FlatMap::reserve_capacity

    fn[K, V] FlatMap::reserve_capacity(self : FlatMap[K, V], capacity~ : Int) -> Unit

    FlatMap::set

    fn[K : Compare + Eq, V] FlatMap::set(self : FlatMap[K, V], key : K, value : V) -> V?

    FlatMap::shrink_to_fit

    fn[K, V] FlatMap::shrink_to_fit(self : FlatMap[K, V]) -> Unit

    FlatMap::to_string

    fn[K : Show, V : Show] FlatMap::to_string(self : FlatMap[K, V]) -> String

    FlatMap::values

    fn[K, V] FlatMap::values(self : FlatMap[K, V]) -> Iter[V]

    FlatMultiMap

    pub struct FlatMultiMap[K, V] {
    entries : Array[(K, V)]
    }

    A multimap held as a sorted array of pairs: keys in order, and the values of one key in order among themselves. Repeats are kept, so this is the flat counterpart of SortedMultiMap.

    test {
    let map : @map.FlatMultiMap[Int32, String] = @map.FlatMultiMap::new()
    map.insert(2, "b")
    map.insert(1, "a")
    map.insert(1, "c")
    @test.assert_eq(map.get(1), ["a", "c"])
    @test.assert_eq(map.length(), 3)
    @test.assert_eq(map.key_count(), 2)
    }
    impl Eq for FlatMultiMap[K, V]
    impl Show for FlatMultiMap[K, V]

    FlatMultiMap::clear

    fn[K, V] FlatMultiMap::clear(self : FlatMultiMap[K, V]) -> Unit

    FlatMultiMap::contains

    fn[K : Compare + Eq, V] FlatMultiMap::contains(self : FlatMultiMap[K, V], key : K) -> Bool

    FlatMultiMap::copy

    fn[K, V] FlatMultiMap::copy(self : FlatMultiMap[K, V]) -> FlatMultiMap[K, V]

    FlatMultiMap::count

    fn[K : Compare + Eq, V] FlatMultiMap::count(self : FlatMultiMap[K, V], key : K) -> Int

    FlatMultiMap::equal

    fn[K : Eq, V : Eq] FlatMultiMap::equal(self : FlatMultiMap[K, V], other : FlatMultiMap[K, V]) -> Bool

    FlatMultiMap::first

    fn[K, V] FlatMultiMap::first(self : FlatMultiMap[K, V]) -> (K, V)?

    FlatMultiMap::get

    fn[K : Compare + Eq, V] FlatMultiMap::get(self : FlatMultiMap[K, V], key : K) -> Array[V]

    FlatMultiMap::insert

    fn[K : Compare + Eq, V : Compare + Eq] FlatMultiMap::insert(self : FlatMultiMap[K, V], key : K, value : V) -> Unit

    FlatMultiMap::is_empty

    fn[K, V] FlatMultiMap::is_empty(self : FlatMultiMap[K, V]) -> Bool

    FlatMultiMap::iter

    fn[K, V] FlatMultiMap::iter(self : FlatMultiMap[K, V]) -> Iter[(K, V)]

    FlatMultiMap::key_count

    fn[K : Compare + Eq, V] FlatMultiMap::key_count(self : FlatMultiMap[K, V]) -> Int

    FlatMultiMap::last

    fn[K, V] FlatMultiMap::last(self : FlatMultiMap[K, V]) -> (K, V)?

    FlatMultiMap::length

    fn[K, V] FlatMultiMap::length(self : FlatMultiMap[K, V]) -> Int

    FlatMultiMap::new

    fn[K, V] FlatMultiMap::new(capacity? : Int) -> FlatMultiMap[K, V]

    FlatMultiMap::not_equal

    fn[K : Eq, V : Eq] FlatMultiMap::not_equal(x : FlatMultiMap[K, V], y : FlatMultiMap[K, V]) -> Bool

    FlatMultiMap::output

    fn[K : Show, V : Show] FlatMultiMap::output(self : FlatMultiMap[K, V], logger : &Logger) -> Unit

    FlatMultiMap::pop_first

    fn[K, V] FlatMultiMap::pop_first(self : FlatMultiMap[K, V]) -> (K, V)?

    FlatMultiMap::pop_last

    fn[K, V] FlatMultiMap::pop_last(self : FlatMultiMap[K, V]) -> (K, V)?

    FlatMultiMap::range

    fn[K : Compare + Eq, V] FlatMultiMap::range(self : FlatMultiMap[K, V], start~ : K, end~ : K) -> Iter[(K, V)]

    FlatMultiMap::remove

    fn[K : Compare + Eq, V] FlatMultiMap::remove(self : FlatMultiMap[K, V], key : K) -> Array[V]

    Drops every value of key and returns them.

    FlatMultiMap::remove_entry

    fn[K : Compare + Eq, V : Compare + Eq] FlatMultiMap::remove_entry(self : FlatMultiMap[K, V], key : K, value : V) -> Bool

    Drops one pair equal to (key, value).

    FlatMultiMap::to_array

    fn[K, V] FlatMultiMap::to_array(self : FlatMultiMap[K, V]) -> Array[(K, V)]

    FlatMultiMap::to_string

    fn[K : Show, V : Show] FlatMultiMap::to_string(self : FlatMultiMap[K, V]) -> String

    FlatSet

    pub struct FlatSet[K] {
    keys : Array[K]
    }

    A set held as a sorted array of elements, the companion of FlatMap.

    test {
    let set : @map.FlatSet[Int32] = @map.FlatSet::new()
    @test.assert_eq(set.insert(3), true)
    @test.assert_eq(set.insert(3), false)
    @test.assert_eq(set.get_index(0), Some(3))
    }
    impl Eq for FlatSet[K]
    impl Show for FlatSet[K]

    FlatSet::capacity

    fn[K] FlatSet::capacity(self : FlatSet[K]) -> Int

    FlatSet::clear

    fn[K] FlatSet::clear(self : FlatSet[K]) -> Unit

    FlatSet::contains

    fn[K : Compare + Eq] FlatSet::contains(self : FlatSet[K], key : K) -> Bool

    FlatSet::copy

    fn[K] FlatSet::copy(self : FlatSet[K]) -> FlatSet[K]

    FlatSet::equal

    fn[K : Eq] FlatSet::equal(self : FlatSet[K], other : FlatSet[K]) -> Bool

    FlatSet::first

    fn[K] FlatSet::first(self : FlatSet[K]) -> K?

    FlatSet::from_array

    fn[K : Compare + Eq] FlatSet::from_array(values : ArrayView[K]) -> FlatSet[K]

    FlatSet::get_index

    fn[K] FlatSet::get_index(self : FlatSet[K], index : Int) -> K?

    FlatSet::index_of

    fn[K : Compare + Eq] FlatSet::index_of(self : FlatSet[K], key : K) -> Result[Int, Int]

    Where key is, or where it would be inserted.

    FlatSet::insert

    fn[K : Compare + Eq] FlatSet::insert(self : FlatSet[K], key : K) -> Bool

    Adds the element and reports whether it was new.

    FlatSet::is_empty

    fn[K] FlatSet::is_empty(self : FlatSet[K]) -> Bool

    FlatSet::iter

    fn[K] FlatSet::iter(self : FlatSet[K]) -> Iter[K]

    FlatSet::last

    fn[K] FlatSet::last(self : FlatSet[K]) -> K?

    FlatSet::length

    fn[K] FlatSet::length(self : FlatSet[K]) -> Int

    FlatSet::new

    fn[K] FlatSet::new(capacity? : Int) -> FlatSet[K]

    FlatSet::not_equal

    fn[K : Eq] FlatSet::not_equal(x : FlatSet[K], y : FlatSet[K]) -> Bool

    FlatSet::output

    fn[K : Show] FlatSet::output(self : FlatSet[K], logger : &Logger) -> Unit

    FlatSet::pop_first

    fn[K] FlatSet::pop_first(self : FlatSet[K]) -> K?

    FlatSet::pop_last

    fn[K] FlatSet::pop_last(self : FlatSet[K]) -> K?

    FlatSet::range

    fn[K : Compare + Eq] FlatSet::range(self : FlatSet[K], start~ : K, end~ : K) -> Iter[K]

    FlatSet::remove

    fn[K : Compare + Eq] FlatSet::remove(self : FlatSet[K], key : K) -> Bool

    FlatSet::reserve_capacity

    fn[K] FlatSet::reserve_capacity(self : FlatSet[K], capacity~ : Int) -> Unit

    FlatSet::shrink_to_fit

    fn[K] FlatSet::shrink_to_fit(self : FlatSet[K]) -> Unit

    FlatSet::to_array

    fn[K] FlatSet::to_array(self : FlatSet[K]) -> Array[K]

    FlatSet::to_string

    fn[K : Show] FlatSet::to_string(self : FlatSet[K]) -> String

    IndexMap

    pub struct IndexMap[K, V] {
    entries : Array[(K, V)]
    hashes : Array[Int]
    slots : Array[Int]
    slot_of : Array[Int]
    live : Int
    graves : Int
    seed : Int
    }

    An associative container that keeps insertion order and gives every entry a position: get_index reads by position, get_index_of reads the position of a key, and the entries can be reordered without touching the table's contents. swap_remove is the default removal because it is O(1); a caller that needs the remaining positions to stay contiguous uses shift_remove.

    test {
    let map : @map.IndexMap[String, Int32] = @map.IndexMap::new()
    let _ = map.set("a", 1)
    let _ = map.set("b", 2)
    @test.assert_eq(map.get_index_of("b"), Some(1))
    @test.assert_eq(map.get_index(0), Some(("a", 1)))
    let _ = map.swap_remove("a")
    @test.assert_eq(map.get_index(0), Some(("b", 2)))
    }
    impl Eq for IndexMap[K, V]
    impl Hash for IndexMap[K, V]
    impl Show for IndexMap[K, V]

    IndexMap::capacity

    fn[K, V] IndexMap::capacity(self : IndexMap[K, V]) -> Int

    The number of slots the table has, which is what reserve_capacity raises.

    IndexMap::clear

    fn[K, V] IndexMap::clear(self : IndexMap[K, V]) -> Unit

    IndexMap::contains

    fn[K : Hash + Eq, V] IndexMap::contains(self : IndexMap[K, V], key : K) -> Bool

    IndexMap::copy

    fn[K, V] IndexMap::copy(self : IndexMap[K, V]) -> IndexMap[K, V]

    IndexMap::equal

    fn[K : Eq, V : Eq] IndexMap::equal(self : IndexMap[K, V], other : IndexMap[K, V]) -> Bool

    IndexMap::from_array

    fn[K : Hash + Eq, V] IndexMap::from_array(entries : ArrayView[(K, V)], hash_seed? : Int) -> IndexMap[K, V]

    IndexMap::from_iter

    fn[K : Hash + Eq, V] IndexMap::from_iter(entries : Iter[(K, V)], hash_seed? : Int) -> IndexMap[K, V]

    IndexMap::get

    fn[K : Hash + Eq, V] IndexMap::get(self : IndexMap[K, V], key : K) -> V?

    IndexMap::get_full

    fn[K : Hash + Eq, V] IndexMap::get_full(self : IndexMap[K, V], key : K) -> (Int, K, V)?

    IndexMap::get_index

    fn[K, V] IndexMap::get_index(self : IndexMap[K, V], index : Int) -> (K, V)?

    IndexMap::get_index_of

    fn[K : Hash + Eq, V] IndexMap::get_index_of(self : IndexMap[K, V], key : K) -> Int?

    IndexMap::get_key_value

    fn[K : Hash + Eq, V] IndexMap::get_key_value(self : IndexMap[K, V], key : K) -> (K, V)?

    The key and the value of an entry, which unlike get hands back the key the map actually holds.

    IndexMap::hash

    fn[K : Hash, V : Hash] IndexMap::hash(self : IndexMap[K, V]) -> Int

    IndexMap::hash_combine

    fn[K : Hash, V : Hash] IndexMap::hash_combine(self : IndexMap[K, V], hasher : Hasher) -> Unit

    IndexMap::insert_full

    fn[K : Hash + Eq, V] IndexMap::insert_full(self : IndexMap[K, V], key : K, value : V) -> (Int, V?)

    The entry index of key after storing value there, and the value that was there before. The position of an existing entry does not change.

    IndexMap::is_empty

    fn[K, V] IndexMap::is_empty(self : IndexMap[K, V]) -> Bool

    IndexMap::iter

    fn[K, V] IndexMap::iter(self : IndexMap[K, V]) -> Iter[(K, V)]

    IndexMap::iter2

    fn[K, V] IndexMap::iter2(self : IndexMap[K, V]) -> Iter2[K, V]

    IndexMap::keys

    fn[K, V] IndexMap::keys(self : IndexMap[K, V]) -> Iter[K]

    IndexMap::length

    fn[K, V] IndexMap::length(self : IndexMap[K, V]) -> Int

    IndexMap::move_index

    fn[K, V] IndexMap::move_index(self : IndexMap[K, V], from : Int, to : Int) -> Unit

    Moves the entry at from to to, shifting everything between them.

    IndexMap::new

    fn[K, V] IndexMap::new(capacity? : Int, hash_seed? : Int) -> IndexMap[K, V]

    A table with room for capacity entries, laid out from hash_seed. A fixed seed makes the layout, and with it nothing visible, reproducible; the order of the entries does not depend on it.

    IndexMap::not_equal

    fn[K : Eq, V : Eq] IndexMap::not_equal(x : IndexMap[K, V], y : IndexMap[K, V]) -> Bool

    IndexMap::output

    fn[K : Show, V : Show] IndexMap::output(self : IndexMap[K, V], logger : &Logger) -> Unit

    IndexMap::range

    fn[K, V] IndexMap::range(self : IndexMap[K, V], start~ : Int, len~ : Int) -> Iter[(K, V)]

    The entries from start for len positions, clamped to the container.

    IndexMap::remove

    fn[K : Hash + Eq, V] IndexMap::remove(self : IndexMap[K, V], key : K) -> V?

    IndexMap::reserve_capacity

    fn[K, V] IndexMap::reserve_capacity(self : IndexMap[K, V], capacity~ : Int) -> Unit

    IndexMap::retain

    fn[K, V] IndexMap::retain(self : IndexMap[K, V], f : (K, V) -> Bool) -> Unit

    Keeps the entries the predicate accepts, in their order, and renumbers the positions when any were dropped.

    IndexMap::set

    fn[K : Hash + Eq, V] IndexMap::set(self : IndexMap[K, V], key : K, value : V) -> V?

    Stores value under key and returns the value it replaced.

    IndexMap::set_default

    fn[K : Hash + Eq, V] IndexMap::set_default(self : IndexMap[K, V], key : K, value : V) -> V

    Stores value under key only when the key is new, which is how a caller keeps the first value written.

    IndexMap::shift_remove

    fn[K : Hash + Eq, V] IndexMap::shift_remove(self : IndexMap[K, V], key : K) -> V?

    IndexMap::shift_remove_index

    fn[K, V] IndexMap::shift_remove_index(self : IndexMap[K, V], index : Int) -> (K, V)?

    Removes the entry at index and closes the gap, so every entry after it moves down one position.

    IndexMap::shrink_to_fit

    fn[K, V] IndexMap::shrink_to_fit(self : IndexMap[K, V]) -> Unit

    IndexMap::sort_by

    fn[K, V] IndexMap::sort_by(self : IndexMap[K, V], cmp : ((K, V), (K, V)) -> Int) -> Unit

    IndexMap::sort_by_key

    fn[K, V, R : Compare + Eq] IndexMap::sort_by_key(self : IndexMap[K, V], project~ : (K) -> R) -> Unit

    IndexMap::sort_keys

    fn[K : Compare + Eq, V] IndexMap::sort_keys(self : IndexMap[K, V]) -> Unit

    Sorts the entries by key and renumbers the positions.

    IndexMap::split_off

    fn[K : Hash + Eq, V] IndexMap::split_off(self : IndexMap[K, V], at : Int) -> IndexMap[K, V]

    The entries from at on, as a new map; this map keeps the ones before it.

    IndexMap::swap_indices

    fn[K, V] IndexMap::swap_indices(self : IndexMap[K, V], a : Int, b : Int) -> Unit

    IndexMap::swap_remove

    fn[K : Hash + Eq, V] IndexMap::swap_remove(self : IndexMap[K, V], key : K) -> V?

    IndexMap::swap_remove_index

    fn[K, V] IndexMap::swap_remove_index(self : IndexMap[K, V], index : Int) -> (K, V)?

    Removes the entry at index by moving the last entry into its place, and returns it. The entry that moved keeps its key and takes the removed position.

    IndexMap::to_array

    fn[K, V] IndexMap::to_array(self : IndexMap[K, V]) -> Array[(K, V)]

    IndexMap::to_string

    fn[K : Show, V : Show] IndexMap::to_string(self : IndexMap[K, V]) -> String

    IndexMap::truncate

    fn[K, V] IndexMap::truncate(self : IndexMap[K, V], length : Int) -> Unit

    IndexMap::update

    fn[K : Hash + Eq, V] IndexMap::update(self : IndexMap[K, V], key : K, f : (V) -> V) -> Bool

    Replaces the value of an entry that is already there, and reports whether there was one.

    IndexMap::values

    fn[K, V] IndexMap::values(self : IndexMap[K, V]) -> Iter[V]

    IndexSet

    pub struct IndexSet[K] {
    map : IndexMap[K, Unit]
    }

    A set that keeps insertion order and gives every element a position, the companion of IndexMap the way HashSet is the companion of HashMap.

    test {
    let set : @map.IndexSet[Int32] = @map.IndexSet::new()
    @test.assert_eq(set.insert(7), (0, true))
    @test.assert_eq(set.insert(7), (0, false))
    @test.assert_eq(set.get_index(0), Some(7))
    }
    impl Eq for IndexSet[K]
    impl Hash for IndexSet[K]
    impl Show for IndexSet[K]

    IndexSet::capacity

    fn[K] IndexSet::capacity(self : IndexSet[K]) -> Int

    IndexSet::clear

    fn[K] IndexSet::clear(self : IndexSet[K]) -> Unit

    IndexSet::contains

    fn[K : Hash + Eq] IndexSet::contains(self : IndexSet[K], value : K) -> Bool

    IndexSet::copy

    fn[K] IndexSet::copy(self : IndexSet[K]) -> IndexSet[K]

    IndexSet::difference

    fn[K : Hash + Eq] IndexSet::difference(self : IndexSet[K], other : IndexSet[K]) -> IndexSet[K]

    The elements of this set that are not in other, in this set's order.

    IndexSet::equal

    fn[K : Eq] IndexSet::equal(self : IndexSet[K], other : IndexSet[K]) -> Bool

    IndexSet::first

    fn[K] IndexSet::first(self : IndexSet[K]) -> K?

    IndexSet::from_array

    fn[K : Hash + Eq] IndexSet::from_array(values : ArrayView[K], hash_seed? : Int) -> IndexSet[K]

    IndexSet::from_iter

    fn[K : Hash + Eq] IndexSet::from_iter(values : Iter[K], hash_seed? : Int) -> IndexSet[K]

    IndexSet::get_index

    fn[K] IndexSet::get_index(self : IndexSet[K], index : Int) -> K?

    IndexSet::get_index_of

    fn[K : Hash + Eq] IndexSet::get_index_of(self : IndexSet[K], value : K) -> Int?

    IndexSet::hash

    fn[K : Hash] IndexSet::hash(self : IndexSet[K]) -> Int

    IndexSet::hash_combine

    fn[K : Hash] IndexSet::hash_combine(self : IndexSet[K], hasher : Hasher) -> Unit

    IndexSet::insert

    fn[K : Hash + Eq] IndexSet::insert(self : IndexSet[K], value : K) -> (Int, Bool)

    The position of the element and whether it was new.

    IndexSet::intersection

    fn[K : Hash + Eq] IndexSet::intersection(self : IndexSet[K], other : IndexSet[K]) -> IndexSet[K]

    IndexSet::is_disjoint

    fn[K : Hash + Eq] IndexSet::is_disjoint(self : IndexSet[K], other : IndexSet[K]) -> Bool

    IndexSet::is_empty

    fn[K] IndexSet::is_empty(self : IndexSet[K]) -> Bool

    IndexSet::is_subset

    fn[K : Hash + Eq] IndexSet::is_subset(self : IndexSet[K], other : IndexSet[K]) -> Bool

    IndexSet::is_superset

    fn[K : Hash + Eq] IndexSet::is_superset(self : IndexSet[K], other : IndexSet[K]) -> Bool

    IndexSet::iter

    fn[K] IndexSet::iter(self : IndexSet[K]) -> Iter[K]

    IndexSet::last

    fn[K] IndexSet::last(self : IndexSet[K]) -> K?

    IndexSet::length

    fn[K] IndexSet::length(self : IndexSet[K]) -> Int

    IndexSet::move_index

    fn[K] IndexSet::move_index(self : IndexSet[K], from : Int, to : Int) -> Unit

    IndexSet::new

    fn[K] IndexSet::new(capacity? : Int, hash_seed? : Int) -> IndexSet[K]

    IndexSet::not_equal

    fn[K : Eq] IndexSet::not_equal(x : IndexSet[K], y : IndexSet[K]) -> Bool

    IndexSet::output

    fn[K : Show] IndexSet::output(self : IndexSet[K], logger : &Logger) -> Unit

    IndexSet::range

    fn[K] IndexSet::range(self : IndexSet[K], start~ : Int, len~ : Int) -> Iter[K]

    The elements from start for len positions.

    IndexSet::remove

    fn[K : Hash + Eq] IndexSet::remove(self : IndexSet[K], value : K) -> Bool

    IndexSet::retain

    fn[K] IndexSet::retain(self : IndexSet[K], f : (K) -> Bool) -> Unit

    IndexSet::shift_remove

    fn[K : Hash + Eq] IndexSet::shift_remove(self : IndexSet[K], value : K) -> Bool

    IndexSet::sort_by

    fn[K] IndexSet::sort_by(self : IndexSet[K], cmp : (K, K) -> Int) -> Unit

    IndexSet::sort_keys

    fn[K : Compare + Eq] IndexSet::sort_keys(self : IndexSet[K]) -> Unit

    IndexSet::swap_indices

    fn[K] IndexSet::swap_indices(self : IndexSet[K], a : Int, b : Int) -> Unit

    IndexSet::swap_remove

    fn[K : Hash + Eq] IndexSet::swap_remove(self : IndexSet[K], value : K) -> Bool

    IndexSet::symmetric_difference

    fn[K : Hash + Eq] IndexSet::symmetric_difference(self : IndexSet[K], other : IndexSet[K]) -> IndexSet[K]

    IndexSet::to_array

    fn[K] IndexSet::to_array(self : IndexSet[K]) -> Array[K]

    IndexSet::to_string

    fn[K : Show] IndexSet::to_string(self : IndexSet[K]) -> String

    IndexSet::union

    fn[K : Hash + Eq] IndexSet::union(self : IndexSet[K], other : IndexSet[K]) -> IndexSet[K]

    The elements of this set followed by the ones only other has.

    MultiMap

    pub struct MultiMap[K, V] {
    map : IndexMap[K, Array[V]]
    total : Int
    }

    A map from a key to a list of values: one entry per key, and the values of a key keep the order they were inserted in.

    test {
    let map : @map.MultiMap[String, Int32] = @map.MultiMap::new()
    map.insert("a", 1)
    map.insert("a", 2)
    @test.assert_eq(map.get("a"), [1, 2])
    @test.assert_eq(map.length(), 2)
    @test.assert_eq(map.key_count(), 1)
    }
    impl Eq for MultiMap[K, V]
    impl Show for MultiMap[K, V]

    MultiMap::clear

    fn[K, V] MultiMap::clear(self : MultiMap[K, V]) -> Unit

    MultiMap::contains

    fn[K : Hash + Eq, V] MultiMap::contains(self : MultiMap[K, V], key : K) -> Bool

    MultiMap::contains_entry

    fn[K : Hash + Eq, V : Eq] MultiMap::contains_entry(self : MultiMap[K, V], key : K, value : V) -> Bool

    MultiMap::copy

    fn[K : Hash + Eq, V] MultiMap::copy(self : MultiMap[K, V]) -> MultiMap[K, V]

    MultiMap::equal

    fn[K : Eq, V : Eq] MultiMap::equal(self : MultiMap[K, V], other : MultiMap[K, V]) -> Bool

    MultiMap::get

    fn[K : Hash + Eq, V] MultiMap::get(self : MultiMap[K, V], key : K) -> Array[V]

    The values of key, in insertion order. The array is a copy, so a caller cannot write into the map through it.

    MultiMap::insert

    fn[K : Hash + Eq, V] MultiMap::insert(self : MultiMap[K, V], key : K, value : V) -> Unit

    MultiMap::is_empty

    fn[K, V] MultiMap::is_empty(self : MultiMap[K, V]) -> Bool

    MultiMap::iter

    fn[K, V] MultiMap::iter(self : MultiMap[K, V]) -> Iter[(K, V)]

    Every pair, key by key, the values of a key in insertion order.

    MultiMap::iter2

    fn[K, V] MultiMap::iter2(self : MultiMap[K, V]) -> Iter2[K, V]

    MultiMap::iter_values

    fn[K : Hash + Eq, V] MultiMap::iter_values(self : MultiMap[K, V], key : K) -> Iter[V]

    MultiMap::key_count

    fn[K, V] MultiMap::key_count(self : MultiMap[K, V]) -> Int

    The number of distinct keys.

    MultiMap::keys

    fn[K, V] MultiMap::keys(self : MultiMap[K, V]) -> Iter[K]

    MultiMap::length

    fn[K, V] MultiMap::length(self : MultiMap[K, V]) -> Int

    The number of values held, counting repeats.

    MultiMap::new

    fn[K, V] MultiMap::new(capacity? : Int, hash_seed? : Int) -> MultiMap[K, V]

    MultiMap::not_equal

    fn[K : Eq, V : Eq] MultiMap::not_equal(x : MultiMap[K, V], y : MultiMap[K, V]) -> Bool

    MultiMap::output

    fn[K : Show, V : Show] MultiMap::output(self : MultiMap[K, V], logger : &Logger) -> Unit

    MultiMap::remove

    fn[K : Hash + Eq, V] MultiMap::remove(self : MultiMap[K, V], key : K) -> Array[V]

    Drops every value of key and returns them.

    MultiMap::remove_entry

    fn[K : Hash + Eq, V : Eq] MultiMap::remove_entry(self : MultiMap[K, V], key : K, value : V) -> Bool

    Drops one occurrence of value under key.

    MultiMap::to_string

    fn[K : Show, V : Show] MultiMap::to_string(self : MultiMap[K, V]) -> String

    Overlap

    pub(all) enum Overlap {
    Overwrite
    Refuse
    KeepFirst
    } derive(Eq,
    Debug
    )

    What an insert does when the new range meets one that is already there.
    impl Show for Overlap

    Overlap::equal

    fn Overlap::equal(Overlap, Overlap) -> Bool

    Overlap::not_equal

    fn Overlap::not_equal(x : Overlap, y : Overlap) -> Bool

    Overlap::output

    fn Overlap::output(self : Overlap, logger : &Logger) -> Unit

    Overlap::to_repr

    Overlap::to_string

    fn Overlap::to_string(self : Overlap) -> String

    RadixTree

    pub struct RadixTree[T] {
    labels : Array[Array[Char]]
    children : Array[Map[Char, Int]]
    values : Array[T?]
    entries : Int
    }

    A trie with its chains of single-child nodes collapsed into one edge per label: a lookup compares whole labels instead of single characters, which is what keeps a tree over long shared prefixes shallow. The surface is the Trie surface, plus the queries that only make sense over a compressed tree: the keys that are prefixes of a given key, a count of the keys under a prefix, and a scan of that subtree.

    test {
    let tree : @map.RadixTree[Int32] = @map.RadixTree::new()
    @test.assert_eq(tree.insert("car", 1), None)
    @test.assert_eq(tree.insert("cart", 2), None)
    @test.assert_eq(tree.insert("cat", 3), None)
    @test.assert_eq(tree.get("cart"), Some(2))
    @test.assert_eq(tree.get_ancestor_keys("cartoon"), ["car", "cart"])
    @test.assert_eq(tree.prefix_count("ca"), 3)
    }
    impl Show for RadixTree[T]

    RadixTree::clear

    fn[T] RadixTree::clear(self : RadixTree[T]) -> Unit

    RadixTree::contains

    fn[T] RadixTree::contains(self : RadixTree[T], key : StringView) -> Bool

    RadixTree::contains_prefix

    fn[T] RadixTree::contains_prefix(self : RadixTree[T], prefix : StringView) -> Bool

    RadixTree::copy

    fn[T] RadixTree::copy(self : RadixTree[T]) -> RadixTree[T]

    RadixTree::get

    fn[T] RadixTree::get(self : RadixTree[T], key : StringView) -> T?

    RadixTree::get_ancestor_keys

    fn[T] RadixTree::get_ancestor_keys(self : RadixTree[T], key : StringView) -> Array[String]

    The stored keys that are prefixes of key, shortest first.

    RadixTree::insert

    fn[T] RadixTree::insert(self : RadixTree[T], key : StringView, value : T) -> T?

    Stores value under key and returns what the key held before.

    RadixTree::is_empty

    fn[T] RadixTree::is_empty(self : RadixTree[T]) -> Bool

    RadixTree::iter

    fn[T] RadixTree::iter(self : RadixTree[T]) -> Iter[(String, T)]

    RadixTree::iter_prefix

    fn[T] RadixTree::iter_prefix(self : RadixTree[T], prefix : StringView) -> Iter[(String, T)]

    The keys under prefix, in character order.

    RadixTree::keys_with_prefix

    fn[T] RadixTree::keys_with_prefix(self : RadixTree[T], prefix : StringView) -> Array[String]

    RadixTree::length

    fn[T] RadixTree::length(self : RadixTree[T]) -> Int

    RadixTree::longest_prefix

    fn[T] RadixTree::longest_prefix(self : RadixTree[T], text : StringView) -> (String, T)?

    The longest stored key that is a prefix of text, with its value.

    RadixTree::new

    fn[T] RadixTree::new() -> RadixTree[T]

    RadixTree::output

    fn[T : Show] RadixTree::output(self : RadixTree[T], logger : &Logger) -> Unit

    RadixTree::prefix_count

    fn[T] RadixTree::prefix_count(self : RadixTree[T], prefix : StringView) -> Int

    How many stored keys start with prefix.

    RadixTree::remove

    fn[T] RadixTree::remove(self : RadixTree[T], key : StringView) -> T?

    Drops the value under key, and the nodes the removal left empty.

    RadixTree::to_array

    fn[T] RadixTree::to_array(self : RadixTree[T]) -> Array[(String, T)]

    RadixTree::to_string

    fn[T : Show] RadixTree::to_string(self : RadixTree[T]) -> String

    RangeMap

    pub struct RangeMap[K, V] {
    ranges : Array[(K, K, V)]
    overlap : Overlap
    }

    A value that holds over a span of keys: the ranges are kept sorted, never overlap each other, and two ranges that touch and hold the same value are kept as one. A range is half-open — it covers start and stops before end — so an insert that meets a neighbour at one endpoint does not collide with it.

    test {
    let map : @map.RangeMap[Int32, String] = @map.RangeMap::new()
    map.insert(start=0, end=10, "low")
    map.insert(start=10, end=20, "high")
    @test.assert_eq(map.get(5), Some("low"))
    @test.assert_eq(map.get(10), Some("high"))
    @test.assert_eq(map.get(20), None)
    @test.assert_eq(map.length(), 2)
    }
    impl Eq for RangeMap[K, V]
    impl Show for RangeMap[K, V]

    RangeMap::clear

    fn[K, V] RangeMap::clear(self : RangeMap[K, V]) -> Unit

    RangeMap::copy

    fn[K, V] RangeMap::copy(self : RangeMap[K, V]) -> RangeMap[K, V]

    RangeMap::equal

    fn[K : Eq, V : Eq] RangeMap::equal(self : RangeMap[K, V], other : RangeMap[K, V]) -> Bool

    RangeMap::gaps

    fn[K, V] RangeMap::gaps(self : RangeMap[K, V]) -> Iter[(K, K)]

    The spans no range covers, in start order.

    RangeMap::get

    fn[K : Compare + Eq, V] RangeMap::get(self : RangeMap[K, V], key : K) -> V?

    RangeMap::get_range

    fn[K : Compare + Eq, V] RangeMap::get_range(self : RangeMap[K, V], key : K) -> (K, K, V)?

    RangeMap::insert

    fn[K : Compare + Eq, V : Eq] RangeMap::insert(self : RangeMap[K, V], start~ : K, end~ : K, value : V) -> Unit raise
    Refused

    Stores value over [start, end), applying the overlap policy and folding the result into its neighbours.

    RangeMap::is_empty

    fn[K, V] RangeMap::is_empty(self : RangeMap[K, V]) -> Bool

    RangeMap::length

    fn[K, V] RangeMap::length(self : RangeMap[K, V]) -> Int

    RangeMap::new

    fn[K, V] RangeMap::new(overlap? : Overlap) -> RangeMap[K, V]

    RangeMap::not_equal

    fn[K : Eq, V : Eq] RangeMap::not_equal(x : RangeMap[K, V], y : RangeMap[K, V]) -> Bool

    RangeMap::output

    fn[K : Show, V : Show] RangeMap::output(self : RangeMap[K, V], logger : &Logger) -> Unit

    RangeMap::overlapping

    fn[K : Compare + Eq, V] RangeMap::overlapping(self : RangeMap[K, V], start~ : K, end~ : K) -> Array[(K, K, V)]

    Every range that meets [start, end), in start order.

    RangeMap::ranges

    fn[K, V] RangeMap::ranges(self : RangeMap[K, V]) -> Iter[(K, K, V)]

    The ranges, in start order.

    RangeMap::remove

    fn[K : Compare + Eq, V] RangeMap::remove(self : RangeMap[K, V], start~ : K, end~ : K) -> Unit

    Drops the part of every range that falls in [start, end), splitting a range that straddles it.

    RangeMap::to_string

    fn[K : Show, V : Show] RangeMap::to_string(self : RangeMap[K, V]) -> String

    RangeSet

    pub struct RangeSet[K] {
    ranges : Array[(K, K)]
    overlap : Overlap
    }

    A set of spans: the companion of RangeMap with no value to carry.

    test {
    let set : @map.RangeSet[Int32] = @map.RangeSet::new()
    set.insert(start=0, end=5)
    set.insert(start=5, end=9)
    @test.assert_eq(set.contains(7), true)
    @test.assert_eq(set.contains(9), false)
    @test.assert_eq(set.length(), 1)
    }
    impl Eq for RangeSet[K]
    impl Show for RangeSet[K]

    RangeSet::clear

    fn[K] RangeSet::clear(self : RangeSet[K]) -> Unit

    RangeSet::contains

    fn[K : Compare + Eq] RangeSet::contains(self : RangeSet[K], key : K) -> Bool

    RangeSet::copy

    fn[K] RangeSet::copy(self : RangeSet[K]) -> RangeSet[K]

    RangeSet::equal

    fn[K : Eq] RangeSet::equal(self : RangeSet[K], other : RangeSet[K]) -> Bool

    RangeSet::gaps

    fn[K] RangeSet::gaps(self : RangeSet[K]) -> Iter[(K, K)]

    RangeSet::insert

    fn[K : Compare + Eq] RangeSet::insert(self : RangeSet[K], start~ : K, end~ : K) -> Unit raise
    Refused

    RangeSet::is_empty

    fn[K] RangeSet::is_empty(self : RangeSet[K]) -> Bool

    RangeSet::length

    fn[K] RangeSet::length(self : RangeSet[K]) -> Int

    RangeSet::new

    fn[K] RangeSet::new(overlap? : Overlap) -> RangeSet[K]

    RangeSet::not_equal

    fn[K : Eq] RangeSet::not_equal(x : RangeSet[K], y : RangeSet[K]) -> Bool

    RangeSet::output

    fn[K : Show] RangeSet::output(self : RangeSet[K], logger : &Logger) -> Unit

    RangeSet::overlapping

    fn[K : Compare + Eq] RangeSet::overlapping(self : RangeSet[K], start~ : K, end~ : K) -> Array[(K, K)]

    RangeSet::ranges

    fn[K] RangeSet::ranges(self : RangeSet[K]) -> Iter[(K, K)]

    RangeSet::remove

    fn[K : Compare + Eq] RangeSet::remove(self : RangeSet[K], start~ : K, end~ : K) -> Unit

    RangeSet::to_string

    fn[K : Show] RangeSet::to_string(self : RangeSet[K]) -> String

    SortedMultiMap

    pub struct SortedMultiMap[K, V] {
    entries : Array[(K, V)]
    }

    A multimap held as a sorted array: the keys are in order, and the values of one key are in order among themselves as well, so range and first walk the pairs in the order a reader expects.

    test {
    let map : @map.SortedMultiMap[Int32, String] = @map.SortedMultiMap::new()
    map.insert(2, "b")
    map.insert(1, "a")
    map.insert(1, "b")
    @test.assert_eq(map.first(), Some((1, "a")))
    @test.assert_eq(map.get(1), ["a", "b"])
    }
    impl Eq for SortedMultiMap[K, V]
    impl Show for SortedMultiMap[K, V]

    SortedMultiMap::clear

    fn[K, V] SortedMultiMap::clear(self : SortedMultiMap[K, V]) -> Unit

    SortedMultiMap::contains

    fn[K : Compare + Eq, V] SortedMultiMap::contains(self : SortedMultiMap[K, V], key : K) -> Bool

    SortedMultiMap::copy

    fn[K, V] SortedMultiMap::copy(self : SortedMultiMap[K, V]) -> SortedMultiMap[K, V]

    SortedMultiMap::equal

    fn[K : Eq, V : Eq] SortedMultiMap::equal(self : SortedMultiMap[K, V], other : SortedMultiMap[K, V]) -> Bool

    SortedMultiMap::first

    fn[K, V] SortedMultiMap::first(self : SortedMultiMap[K, V]) -> (K, V)?

    SortedMultiMap::get

    fn[K : Compare + Eq, V] SortedMultiMap::get(self : SortedMultiMap[K, V], key : K) -> Array[V]

    The values of key, in order.

    SortedMultiMap::insert

    fn[K : Compare + Eq, V : Compare + Eq] SortedMultiMap::insert(self : SortedMultiMap[K, V], key : K, value : V) -> Unit

    SortedMultiMap::is_empty

    fn[K, V] SortedMultiMap::is_empty(self : SortedMultiMap[K, V]) -> Bool

    SortedMultiMap::iter

    fn[K, V] SortedMultiMap::iter(self : SortedMultiMap[K, V]) -> Iter[(K, V)]

    SortedMultiMap::key_count

    fn[K : Compare + Eq, V] SortedMultiMap::key_count(self : SortedMultiMap[K, V]) -> Int

    The number of distinct keys.

    SortedMultiMap::last

    fn[K, V] SortedMultiMap::last(self : SortedMultiMap[K, V]) -> (K, V)?

    SortedMultiMap::length

    fn[K, V] SortedMultiMap::length(self : SortedMultiMap[K, V]) -> Int

    SortedMultiMap::new

    fn[K, V] SortedMultiMap::new() -> SortedMultiMap[K, V]

    SortedMultiMap::not_equal

    fn[K : Eq, V : Eq] SortedMultiMap::not_equal(x : SortedMultiMap[K, V], y : SortedMultiMap[K, V]) -> Bool

    SortedMultiMap::output

    fn[K : Show, V : Show] SortedMultiMap::output(self : SortedMultiMap[K, V], logger : &Logger) -> Unit

    SortedMultiMap::pop_first

    fn[K, V] SortedMultiMap::pop_first(self : SortedMultiMap[K, V]) -> (K, V)?

    SortedMultiMap::pop_last

    fn[K, V] SortedMultiMap::pop_last(self : SortedMultiMap[K, V]) -> (K, V)?

    SortedMultiMap::range

    fn[K : Compare + Eq, V] SortedMultiMap::range(self : SortedMultiMap[K, V], start~ : K, end~ : K) -> Iter[(K, V)]

    The pairs whose keys fall in start up to end, both included.

    SortedMultiMap::remove

    fn[K : Compare + Eq, V] SortedMultiMap::remove(self : SortedMultiMap[K, V], key : K) -> Array[V]

    Drops the values of key and returns them.

    SortedMultiMap::to_array

    fn[K, V] SortedMultiMap::to_array(self : SortedMultiMap[K, V]) -> Array[(K, V)]

    SortedMultiMap::to_string

    fn[K : Show, V : Show] SortedMultiMap::to_string(self : SortedMultiMap[K, V]) -> String

    Trie

    pub struct Trie[T] {
    children : Array[Map[Char, Int]]
    values : Array[T?]
    entries : Int
    }

    A map keyed by String that shares the storage of keys with a common prefix: the walk to a key costs one step per character, whatever else is stored.

    test {
    let trie : @map.Trie[Int32] = @map.Trie::new()
    @test.assert_eq(trie.insert("car", 1), None)
    @test.assert_eq(trie.insert("cart", 2), None)
    @test.assert_eq(trie.get("car"), Some(1))
    @test.assert_eq(trie.keys_with_prefix("ca"), ["car", "cart"])
    @test.assert_eq(trie.longest_prefix("cartoon"), Some(("cart", 2)))
    }
    impl Show for Trie[T]

    Trie::clear

    fn[T] Trie::clear(self : Trie[T]) -> Unit

    Trie::contains

    fn[T] Trie::contains(self : Trie[T], key : StringView) -> Bool

    Trie::contains_prefix

    fn[T] Trie::contains_prefix(self : Trie[T], prefix : StringView) -> Bool

    Whether any key stored here starts with prefix.

    Trie::copy

    fn[T] Trie::copy(self : Trie[T]) -> Trie[T]

    Trie::get

    fn[T] Trie::get(self : Trie[T], key : StringView) -> T?

    Trie::insert

    fn[T] Trie::insert(self : Trie[T], key : StringView, value : T) -> T?

    Stores value under key and returns the value the key held before.

    Trie::is_empty

    fn[T] Trie::is_empty(self : Trie[T]) -> Bool

    Trie::iter

    fn[T] Trie::iter(self : Trie[T]) -> Iter[(String, T)]

    Every pair, in key order.

    Trie::keys_with_prefix

    fn[T] Trie::keys_with_prefix(self : Trie[T], prefix : StringView) -> Array[String]

    The keys starting with prefix, in character order.

    Trie::length

    fn[T] Trie::length(self : Trie[T]) -> Int

    The number of keys that carry a value.

    Trie::longest_prefix

    fn[T] Trie::longest_prefix(self : Trie[T], text : StringView) -> (String, T)?

    The longest key stored here that is a prefix of text, with its value.

    Trie::new

    fn[T] Trie::new() -> Trie[T]

    Trie::output

    fn[T : Show] Trie::output(self : Trie[T], logger : &Logger) -> Unit

    Trie::remove

    fn[T] Trie::remove(self : Trie[T], key : StringView) -> T?

    Drops the value under key and returns it. The nodes stay, so a later insert of a key with the same prefix does not walk the string again.

    Trie::to_array

    fn[T] Trie::to_array(self : Trie[T]) -> Array[(String, T)]

    Trie::to_string

    fn[T : Show] Trie::to_string(self : Trie[T]) -> String