std::sorted_map
A map kept in key order (by cmp), so it walks its entries sorted.
Source: std/sorted_map.volt
Types
struct std::sorted_map
<K: type, V: type, Allocator: std::mem::allocator = std::mem::default_allocator> struct sorted_mapA map ordered by key. Lookups are a binary search. ponytail: sorted arrays, so put and remove move the entries after the key (O(n)); a B-tree if maps with many thousands of keys change often
| Field | |
|---|---|
keys: std::vec<K, Allocator> = {} | sorted by cmp |
vals: std::vec<V, Allocator> = {} | vals[i] is keys[i]'s value |
Methods
<K: type, V: type, A: std::mem::allocator> attach fn new_in(static this: std::sorted_map<K, V>, allocator: A) -> std::sorted_map<K, V, A>an empty sorted_map that allocates from allocator
<K: type, V: type, A: std::mem::allocator> attach fn reserve(this: std::sorted_map<K, V, A>&, n: usize) -> std::mem::mem_error!voidroom for n keys without growing
<K: type, V: type, A: std::mem::allocator> attach fn len(this: std::sorted_map<K, V, A>&) -> usizehow many keys it holds
<K: type, V: type, A: std::mem::allocator> attach fn put(this: std::sorted_map<K, V, A>&, key: K, value: V) -> voidset key to value (an old value for it is deleted)
<K: type, V: type, A: std::mem::allocator> attach fn get(this: std::sorted_map<K, V, A>&, key: K) -> V*the value for key, if there is one
<K: type, V: type, A: std::mem::allocator> attach fn contains(this: std::sorted_map<K, V, A>&, key: K) -> boolwhether key has a value
<K: type, V: type, A: std::mem::allocator> attach fn remove(this: std::sorted_map<K, V, A>&, key: K) -> V?take key's value out of the map
<K: type, V: type, A: std::mem::allocator> attach fn clear(this: std::sorted_map<K, V, A>&) -> voiddelete every key and value
<K: type, V: type, A: std::mem::allocator> attach fn iter(this: std::sorted_map<K, V, A>&) -> std::sorted_map_iter<K, V>for (e) in m.iter(): each entry in key order, with e.value a reference into the map
struct std::sorted_map_iter
<K: type, V: type> struct sorted_map_iterwalks a sorted_map's entries in key order
| Field | |
|---|---|
keys: K[..] | |
vals: V[..] | |
i: usize = 0 | the next entry |
Methods
<K: type, V: type> attach fn next(this: std::sorted_map_iter<K, V>&) -> std::entry<K, V>?the next entry