]> gitweb.factorcode.org Git - factor.git/blob - basis/hash2/hash2-docs.factor
Create basis vocab root
[factor.git] / basis / hash2 / hash2-docs.factor
1 USING: help.syntax help.markup ;
2 IN: hash2
3
4 ARTICLE: { "hash2" "intro" } "Hash2"
5 "The hash2 vocabulary specifies a simple minimal datastructure for hash tables with two integers as keys. These hash tables are fixed size and do not conform to the associative mapping protocol. Words used in creating and manipulating these hash tables include:"
6 { $subsection <hash2> }
7 { $subsection hash2 }
8 { $subsection set-hash2 }
9 { $subsection alist>hash2 } ;
10
11 HELP: <hash2>
12 { $values { "size" "size of the underlying array" } { "hash2" hash2 } }
13 { $description "Creates a " { $link hash2 } " object with the given size of the underlying array. Initially, the hash2 contains nothing." } ;
14
15 HELP: hash2
16 { $values { "a" "first key" } { "b" "second key" } { "hash2" hash2 } { "value/f" "the associated value or f" } }
17 { $description "Looks up the associated value in the hash2 table with the given keys. If a value is found, it is returned, otherwise f is returned. Note that it is significant which order the keys are in." }
18 { $class-description "A hash2 table, with two integers as the key for each value. Hash2 tables are of fixed size and do not conform to the associative mapping protocol." } ;
19
20 HELP: set-hash2
21 { $values { "a" "first key" } { "b" "second key" } { "value" "the new value" } { "hash2" hash2 } }
22 { $description "Sets the hash2 at the given key combination to the given value. Note that the order of keys is significant and that this will never grow the hash2 table. Both keys must be integers." } ;
23
24 HELP: alist>hash2
25 { $values { "alist" "a sequence of the form " { $snippet "{ { a b value } ... }" } } { "size" "the size of the new underlying array" } { "hash2" hash2 } }
26 { $description "Converts an association list, where the first and second elements of each inner sequence is a key and the third is the value, into a " { $link hash2 } " of the given size. Both keys must be integers." } ;