Dict.new.3kaya

Langue: en

Version: March 2009 (fedora - 06/07/09)

Section: 3 (Bibliothèques de fonctions)

NAME

Dict::new - Create a new dictionary.

SYNOPSIS

Dict<a, b> new( Int buckets=157, Int(a) hashfn=hash )

ARGUMENTS

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 1.5*(expected number of entries) , with the default being 157.

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 String , the Builtins.strHash(3kaya) function should be used instead, and if the keys are of type Int you may use 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.

DESCRIPTION

Create a new dictionary.


 d = Dict::new(); // 157 buckets, default hashing function
 d = Dict::new(31,strHash); // 31 buckets, String hashing function 
                            // - suitable for holding about 20 values.

AUTHORS

Kaya standard library by Edwin Brady, Chris Morris and others (kaya@kayalang.org). For further information see http://kayalang.org/

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.

Dict.Dict(3kaya)

Dict.add(3kaya)

Dict.delete(3kaya)

Dict.empty(3kaya)

Dict.entries(3kaya)

Dict.exists(3kaya)

Dict.keys(3kaya)

Dict.lookup(3kaya)

Dict.vals(3kaya)