.\" This man page is automatically generated using .\" kayadoc2man from the Kaya development tools and the -xmldocs compile .\" option. Editing it directly is not encouraged. .\" It is under the same license as the source .k file that it was .\" generated from. .TH "Dict.new" "3kaya" "August 2014" "Kaya" "Kaya module reference" .SH "NAME" Dict::new \- Create a new dictionary. .SH "SYNOPSIS" .B Dict new( \fIInt buckets=157, Int(a) hashfn=hash\fP .B ")" .SH "ARGUMENTS" .PP .B "buckets" The number of hashing buckets to use. A larger number of buckets increases the speed of the dictionary (up to a limit) but uses more memory. A good choice is the nearest prime number to \fB1.5*(expected number of entries) \fP , with the default being 157. .PP .B "hashfn" The function to hash the keys. This function must take a key, and return an integer. A good hashing function will return different values for similar keys (but must of course always return the same value for the same key!). A default built-in hashing function is provided, though if the keys are of type \fBString \fP , the .B "Builtins.strHash"(3kaya) function should be used instead, and if the keys are of type \fBInt \fP you may use .B "Builtins.identity"(3kaya) (though an array may provide faster insertion and lookup if the keys are positive and either small or largely sequential). If the keys are an especially complex data type, it may again be best to write your own hashing function. .SH "DESCRIPTION" .PP Create a new dictionary. .IP "" -4 d = Dict::new(); // 157 buckets, default hashing function d = Dict::new(31,strHash); // 31 buckets, String hashing function // - suitable for holding about 20 values. .SH "AUTHORS" Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/ .SH LICENSE The Kaya standard library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (version 2.1 or any later version) as published by the Free Software Foundation. .SH "RELATED" .PD 0 .PP .B "Dict.Dict"(3kaya) .PP .B "Dict.add"(3kaya) .PP .B "Dict.delete"(3kaya) .PP .B "Dict.empty"(3kaya) .PP .B "Dict.entries"(3kaya) .PP .B "Dict.exists"(3kaya) .PP .B "Dict.keys"(3kaya) .PP .B "Dict.lookup"(3kaya) .PP .B "Dict.vals"(3kaya) .PD 0.4v