Updating linked-assocs documentation, add <linked-assoc> word

db4
Slava Pestov 2008-11-11 17:42:52 -06:00
parent b4683bb00b
commit 5c6860fd0f
2 changed files with 17 additions and 14 deletions

View File

@ -2,22 +2,22 @@ IN: linked-assocs
USING: help.markup help.syntax assocs ;
HELP: linked-assoc
{ $class-description "The class of linked assocs. Linked assoc are implemented by combining an assocs and a dlist. The assoc is used for lookup and retrieval of single values, while the dlist is used for getting lists of keys/values, which will be in insertion order." } ;
{ $class-description "The class of linked assocs. Linked assoc are implemented by combining an assoc with a dlist. The assoc is used for lookup and retrieval of single values, while the dlist is used for getting lists of keys/values, which will be in insertion order." } ;
HELP: <linked-assoc>
{ $values { "exemplar" "an exemplar assoc" } }
{ $description "Creates an empty linked assoc backed by a new instance of the same type as the exemplar." } ;
HELP: <linked-hash>
{ $values { "assoc" "A new linked-assoc" } }
{ $description "Creates a new, empty linked assoc." } ;
{ $values { "assoc" linked-assoc } }
{ $description "Creates an empty linked assoc backed by a hashtable." } ;
ARTICLE: "linked-assocs" "Linked assocs"
"A " { $emphasis "linked assoc" } " is an assoc which combines a hash table and a dlist to form a structure which has the insertion and retrieval characteristics of a hash table, but with the ability to get the items in insertion order."
"A " { $emphasis "linked assoc" } " is an assoc which combines an underlying assoc with a dlist to form a structure which has the insertion and retrieval characteristics of the underlying assoc (typically a hashtable), but with the ability to get the entries in insertion order by calling " { $link >alist } "."
$nl
"Linked assocs implement the following methods from the assoc protocol:"
{ $subsection at* }
{ $subsection assoc-size }
{ $subsection >alist }
{ $subsection set-at }
{ $subsection delete-at }
{ $subsection clear-assoc }
{ $subsection >alist } ;
"Linked assocs are implemented in the " { $vocab-link "linked-assocs" } " vocabulary."
{ $subsection linked-assoc }
{ $subsection <linked-hash> }
{ $subsection <linked-assoc> } ;
ABOUT: "linked-assocs"

View File

@ -1,12 +1,15 @@
! Copyright (C) 2008 Slava Pestov, James Cash.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs arrays kernel deques dlists sequences hashtables fry ;
USING: accessors assocs arrays kernel deques dlists sequences fry ;
IN: linked-assocs
TUPLE: linked-assoc assoc dlist ;
: <linked-assoc> ( exemplar -- assoc )
0 swap new-assoc <dlist> linked-assoc boa ;
: <linked-hash> ( -- assoc )
0 <hashtable> <dlist> linked-assoc boa ;
H{ } <linked-assoc> ;
M: linked-assoc assoc-size assoc>> assoc-size ;