1Dict.new(3kaya) Kaya module reference Dict.new(3kaya)
2
3
4
6 Dict::new - Create a new dictionary.
7
9 Dict<a, b> new( Int buckets=157, Int(a) hashfn=hash )
10
12 buckets The number of hashing buckets to use. A larger number of buck‐
13 ets increases the speed of the dictionary (up to a limit) but uses more
14 memory. A good choice is the nearest prime number to 1.5*(expected num‐
15 ber of entries) , with the default being 157.
16
17 hashfn The function to hash the keys. This function must take a key,
18 and return an integer. A good hashing function will return different
19 values for similar keys (but must of course always return the same
20 value for the same key!). A default built-in hashing function is pro‐
21 vided, though if the keys are of type String , the Builtins.strHash
22 [1m(3kaya) function should be used instead, and if the keys are of type
23 Int you may use Builtins.identity (3kaya) (though an array may provide
24 faster insertion and lookup if the keys are positive and either small
25 or largely sequential). If the keys are an especially complex data
26 type, it may again be best to write your own hashing function.
27
29 Create a new dictionary.
30
31
32 d = Dict::new(); // 157 buckets, default hashing function
33 d = Dict::new(31,strHash); // 31 buckets, String hashing function
34 // - suitable for holding about 20 values.
35
37 Kaya standard library by Edwin Brady, Chris Morris and others
38 (kaya@kayalang.org). For further information see http://kayalang.org/
39
41 The Kaya standard library is free software; you can redistribute it
42 and/or modify it under the terms of the GNU Lesser General Public
43 License (version 2.1 or any later version) as published by the Free
44 Software Foundation.
45
47 Dict.Dict (3kaya)
48 Dict.add (3kaya)
49 Dict.delete (3kaya)
50 Dict.empty (3kaya)
51 Dict.entries (3kaya)
52 Dict.exists (3kaya)
53 Dict.keys (3kaya)
54 Dict.lookup (3kaya)
55 Dict.vals (3kaya)
56
57
58
59Kaya December 2010 Dict.new(3kaya)