up: MULTIDICT | index | Zimbu documentation |
The builtin type multiDict. MultiDicts keep a list of items for each key that is present. It's like a dict where each value is a list. The key type must support the ToString() method. It is used for error messages. The item type must support the Equal() method. This is needed for the has(key, item) method. The item type should support the ToString() method. When missing the string "-object-" is used instead of the actual value. Example: multiDict<string, int> md = NEW() md.add("yes", 1) md.add("yes", 2) IO.WriteLine("multiDict has yes: " .. md.has("yes")) IO.WriteLine("multiDict has yes " .. md.get("yes").Size() .. " times") md.remove("yes") Optionally the multiDict can use a list to remember the order in which keys were added. ToString(), keys() and values() will have the keys in the order they were added. This has a small overhead. Without the list the order of keys depends on the hash value, which is rather arbitrary. The values for a key are always kept in the order they were added.
|
PROC NEW() @public
PROC NEW(bool ordered) @public
PROC NEW(dict<Tkey, list<Titem>> items) @public
PROC NEW(dict<Tkey, list<Titem>> items, bool ordered) @public
PROC NEW(list<dict<Tkey, Titem>> items) @public
PROC NEW(list<dict<Tkey, Titem>> items, bool ordered) @public
FUNC $ToString() string @public
FUNC $add(Tkey key, Titem item) MultiDict<Tkey, Titem> @public
FUNC $addDict(dict<Tkey, list<Titem>> items) MultiDict<Tkey, Titem> @public
FUNC $addList(Tkey key, list<Titem> itemList) MultiDict<Tkey, Titem> @public
FUNC $addList(list<dict<Tkey, Titem>> items) MultiDict<Tkey, Titem> @public
FUNC $clear(Tkey key) MultiDict<Tkey, Titem> @public
FUNC $clear() MultiDict<Tkey, Titem> @public
FUNC $copy() MultiDict<Tkey, Titem> @public
FUNC $count(Tkey key) int @public
FUNC $forEach(proc<Titem> f) multiDict<Tkey, Titem> @public
FUNC $forEachList(proc<list<Titem>> f) multiDict<Tkey, Titem> @public
FUNC $forKeyEach(proc<Tkey, Titem> f) multiDict<Tkey, Titem> @public
FUNC $forKeyEachList(proc<Tkey, list<Titem>> f) multiDict<Tkey, Titem> @public
FUNC $get(Tkey key) list<Titem> @public
FUNC $get(Tkey key, list<Titem> default) list<Titem> @public
FUNC $has(Tkey key) bool @public
FUNC $has(Tkey key, Titem item) bool @public
FUNC $insert(Tkey key, Titem item) MultiDict<Tkey, Titem> @public
FUNC $isOrdered() bool @public
FUNC $keyMap(func<Tkey, Titem => Titem> f) multiDict<Tkey, Titem> @public
FUNC $keyMapList(func<Tkey, list<Titem> => list<Titem>> f) multiDict<Tkey, Titem> @public
FUNC $keyMapListTo<Tresult>(func<Tkey, list<Titem> => list<Tresult>> f) multiDict<Tkey, Tresult> @public
FUNC $keyMapTo<Tresult>(func<Tkey, Titem => Tresult> f) multiDict<Tkey, Tresult> @public
FUNC $keys() list<Tkey> @public
FUNC $map(func<Titem => Titem> f) multiDict<Tkey, Titem> @public
FUNC $mapList(func<list<Titem> => list<Titem>> f) multiDict<Tkey, Titem> @public
FUNC $mapListTo<Tresult>(func<list<Titem> => list<Tresult>> f) multiDict<Tkey, Tresult> @public
FUNC $mapTo<Tresult>(func<Titem => Tresult> f) multiDict<Tkey, Tresult> @public
FUNC $remove(Tkey key, Titem item) MultiDict<Tkey, Titem> @public
FUNC $removeAll(Tkey key) MultiDict<Tkey, Titem> @public
FUNC $set(Tkey key, list<Titem> items) MultiDict<Tkey, Titem> @public
FUNC $values() list<list<Titem>> @public
|
Copyright 2009 Bram Moolenaar All Rights Reserved. |
Licensed under the Apache License, Version 2.0. See the LICENSE file or obtain a copy at: http://www.apache.org/licenses/LICENSE-2.0 |