(use eggdoc) (define doc `((eggdoc:begin (name "sfht") (description "A dictionary data structure based on counting Bloom filters.") (author (url "http://chicken.wiki.br/users/ivan-raikov" "Ivan Raikov")) (history (version "2.4" "Typo fix") (version "2.3" "Ported to Chicken 4") (version "2.1" "Build script updated for better cross-platform compatibility") (version "2.0" "Introduced an API that is independent of the RNG used") (version "1.3" "Documentation updates") (version "1.2" "License upgrade to GPL v3") (version "1.1" "Added random-swb to the list of dependencies") (version "1.0" "Initial release")) (requires (url "sparse-vectors.html" "sparse-vectors")) (usage "(require-extension sfht)") (download "sfht.egg") (documentation (p "The sfht library is an implementation of the Shared-node " "Fast Hash Table (SFHT) data structure described by Song, et al., in " (pre "_Fast Hash Table Lookup Using Extended Bloom Filter: " "An Aid to Network Processing_. (SIGCOMM'05)") ". ") (p "This code defines an " (tt "sfht") " object that implements a " "dictionary mapping of keys to values. The object responds to " "messages for querying, insertion of new elements, and deletion " "of existing elements. The interface of the " (tt "sfht") " object " "is particularly suitable for situations where the keys are " "represented by bit vectors or vectors of fixnum values. ") (p "A counting Bloom filter is a Bloom filter that has been extended so " "that each bit of the filter has a counter associated with it. Upon " "insertion or deletion of an element, the counter is incremented or " "decremented, respectively. In order to find an element efficiently, " "we need to compute the " (tt "k") " hash values, read the counters " "at the " (tt "k") " locations, determine the smallest bucket size, " "and perform a linear search of that bucket for the element. ") (subsection "SFHT procedures" (p "The sfht object is created by a make-sfht function, " "the only user-visible function defined in this egg: ") (procedure "make-sfht:: N P MAKE-RNG-STATE RANDOM! KEY->VECTOR KEY-VECTOR-REF KEY-VECTOR-LENGTH [KEY-EQUAL?] -> SELECTOR" (p "where " (symbol-table (describe "MAKE-RNG-STATE" ("is a user-supplied function that takes in an integer argument and " "returns an RNG state value. " )) (describe "RANDOM!" ("is a user-supplied function that generates a random positive integer, " "given a state value, which is expected to be mutated. " )) (describe "KEY->VECTOR" ("is a user-supplied function that takes a key value " "and returns a vector.")) (describe "KEY-VECTOR-REF" ("is a user-supplied function that retrieves an element from " "the vector returned by " (tt "KEY-VECTOR") ". ")) (describe "KEY-VECTOR-LENGTH" ("is a user-supplied function that returns the length " "of the key vector.")) (describe "KEY->EQUAL?" ("is a user-supplied predicate that takes two keys and returns " (tt "#t") " if they are equal. The default function used is " (tt "equal?"))))) (p "The returned selector procedure can take one of the following arguments: " (symbol-table (describe "'get" ("returns a procedure " (tt "LAMBDA KEY . DEFAULT-CLAUSE") " which searches the hash table for an association with a given " (tt "KEY") ", and returns a (key . value) pair of the found association. " "If an association with " (tt "KEY") " cannot be located in the hash table, " "the PROC returns the result of evaluating the " (tt "DEFAULT-CLAUSE") ". " "If the default clause is omitted, an error is signaled. " (tt "KEY") " must be comparable to the keys in the hash table " "by the " (tt "KEY-EQUAL?") " predicate specified " "when the hash table was created)")) (describe "'empty?" ("returns " (tt "#t") " if the hash table is empty")) (describe "'size" ("returns the size (the number of associations) in the hash table")) (describe "'clear!" ("removes all associations from the hash table (thus making it empty)")) (describe "'put!" ("returns a procedure " (tt "LAMBDA KEY VALUE") " which, given a " (tt "KEY") " and a " (tt "VALUE") ", adds the corresponding association to the hash table. " "If an association with the same " (tt "KEY") " already exists, its value is replaced with the " (tt "VALUE") ". The return value is " (tt "#f") ".")) (describe "'delete!" ("returns a procedure " (tt "LAMBDA KEY . DEFAULT-CLAUSE") " which searches the hash table for an association with a given " (tt "KEY") ", deletes it, and returns a (key . value) pair of the found " "and deleted association. If an association with the KEY cannot be located " "in the hash table, the " (tt "PROC") " returns the result of evaluating " (tt "DEFAULT-CLAUSE") ". " "If the default clause is omitted, an error is signaled. ")) (describe "'debugprint" ("prints out all the contents the Bloom filter, for debug purposes"))))))) (examples (pre #<bit-vector (compose (lambda (x) (if x 1 0)) bit-vector-ref) bit-vector-length)) ((sfht 'put!) 1 'one) ((sfht 'get)) EOF )) (license "Copyright 2007-2009 Ivan Raikov. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or at your option any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A full copy of the GPL license can be found at .")))) (if (eggdoc->html doc) (void))