hashtable - Factor Documentation (original) (raw)

Class description
The class of hashtables. See Hashtable syntax for syntax and Hashtables for general information.

USING: assocs core-foundation core-foundation.dictionaries
core-foundation.utilities hashtables kernel ;

M: hashtable (>cf)
[ [ (>cf) &CFRelease ] bi@ ] assoc-map ;

USING: gml.types hashtables kernel ;

M: hashtable (gml-copy) clone ;

USING: assocs gml.types hashtables ;

M: hashtable (gml-get) of ;

USING: assocs gml.types hashtables ;

M:: hashtable (gml-put) ( collection key elt -- )
elt key collection set-at ;

USING: assocs fjsc hashtables kernel sequences ;

M: hashtable (parse-factor-quotation)
>alist [ (parse-factor-quotation) ] { } map-as
ast-hashtable boa ;

USING: assocs hashtables io kernel serialize serialize.private ;

M: hashtable (serialize)
[ 104 write1 [ add-object ] [ >alist (serialize) ] bi ]
serialize-shared ;

USING: arrays assocs hashtables hashtables.private ;

M: hashtable >alist [ 2array ] collect-pairs ;

USING: assocs hashtables prettyprint.custom ;

M: hashtable >pprint-sequence >alist ;

USING: assocs hashtables kernel python ;

M: hashtable >py [ [ >py ] bi@ ] assoc-map assoc>py-dict ;

USING: assocs hashtables kernel ;

M: hashtable assoc-like
drop dup hashtable? [ >hashtable ] unless ; inline

USING: accessors assocs hashtables kernel math ;

M: hashtable assoc-size [ count>> ] [ deleted>> ] bi - ; inline

USING: assocs hashtables hashtables.private kernel math.private
slots.private ;

M: hashtable at*
key@ [ 3 fixnum+fast slot t ] [ 2drop f f ] if ;

USING: accessors cursors cursors.private hashtables kernel ;

M: hashtable begin-cursor
dup array>> 0 (inc-hashtable-cursor) ;
inline

USING: accessors assocs hashtables hashtables.private kernel
sequences ;

M: hashtable clear-assoc
[ init-hash ] [ array>> [ drop +empty+ ] map! drop ] bi ;

USING: accessors hashtables kernel ;

M: hashtable clone (clone) [ clone ] change-array ; inline

USING: assocs hashtables hashtables.private kernel ;

M: hashtable delete-at
[ nip ] [ key@ ] 2bi
[ [ +tombstone+ dup ] 2dip set-nth-pair hash-deleted+ ]
[ 3drop ] if ;

USING: assocs hashtables kernel npm ;

M: hashtable deps "dependencies" of { } or ;

USING: assocs hashtables kernel npm ;

M: hashtable dev-deps "devDependencies" of { } or ;

USING: accessors cursors cursors.private hashtables kernel
sequences ;

M: hashtable end-cursor
dup array>> length ; inline

USING: assocs hashtables kernel ;

M: hashtable equal? over hashtable? [ assoc= ] [ 2drop f ] if ;

USING: assocs hashtables kernel math ;

M: hashtable hashcode*
[
dup assoc-size 1 eq?
[ assoc-hashcode ] [ nip assoc-size ] if
] recursive-hashcode ;

USING: arrays assocs hashtables kernel.private sequences.private
sorting ;

M: hashtable inv-sort-keys
>alist [ { array } declare first-unsafe ] inv-sort-by ;

USING: arrays assocs hashtables kernel.private sequences.private
sorting ;

M: hashtable inv-sort-values
>alist [ { array } declare second-unsafe ] inv-sort-by ;

USING: assocs hashtables xml-rpc xml.data xml.syntax.private ;

M: hashtable item>xml
[ struct-member ] { } assoc>map 1 nenum T{ xml-chunk
{ seq
V{
""
T{ tag { name ~name~ } { children ~vector~ } }
""
}
}
} interpolate-xml ;

USING: assocs hashtables hashtables.private kernel ;

M: hashtable keys [ drop ] collect-pairs ;

USING: accessors generic hashtables sorting ui.tools.inspector ;

M: hashtable make-slot-descriptions
M\ hashtable make-slot-descriptions (call-next-method)
[ key-string>> ] sort-by ;

USING: assocs hashtables kernel make pdf.values ;

M: hashtable pdf-value
[
"<<\n" % [ swap % " " % pdf-value % "\n" % ] assoc-each
">>" %
] "" make ;

USING: hashtables prettyprint.backend prettyprint.custom ;

M: hashtable pprint*
[ pprint-object ] with-extra-nesting-level ;

USING: hashtables kernel prettyprint.custom ;

M: hashtable pprint-delims drop \ H{ \ } ;

USING: hashtables kernel prettyprint.custom ;

M: hashtable pprint-narrow? drop t ;

USING: hashtables tools.crossref.private ;

M: hashtable quot-uses assoc-uses ;

USING: accessors arrays assocs hashtables hashtables.private
kernel math random sequences.private ;

M: hashtable random*
[ dup assoc-size [ drop f ] ] dip [ random* ] curry
[ [ [ 0 ] [ array>> ] ] ] dip [
tri* 1 +
[ [ 2dup array-nth tombstone? [ 2 + ] 2dip ] loop ]
times [ 2 - ] dip
[ array-nth ] [ [ 1 + ] dip array-nth ] 2bi 2array
] curry compose if-zero ;

USING: assocs hashtables kernel locals.rewrite make ;

M: hashtable rewrite-element
dup rewrite-literal?
[ >alist rewrite-sequence \ >hashtable , ] [ , ] if ;

USING: assocs hashtables locals.rewrite ;

M: hashtable rewrite-literal? >alist rewrite-literal? ;

USING: hashtables locals.rewrite ;

M: hashtable rewrite-sugar* rewrite-element ;

USING: assocs hashtables hashtables.private kernel ;

M: hashtable set-at dup ?grow-hash (set-at) ;

USING: arrays assocs hashtables kernel.private sequences.private
sorting ;

M: hashtable sort-keys
>alist [ { array } declare first-unsafe ] sort-by ;

USING: arrays assocs hashtables kernel.private sequences.private
sorting ;

M: hashtable sort-values
>alist [ { array } declare second-unsafe ] sort-by ;

USING: accessors assocs hashtables hashtables.private kernel
sequences vectors ;

M: hashtable unzip
[ assoc-size dup [ ] bi@ ] [ array>> ] bi
[ [ suffix! ] bi-curry@ bi* ] each-pair [ { } like ] bi@ ;

USING: assocs hashtables hashtables.private kernel ;

M: hashtable values [ nip ] collect-pairs ;

USING: assocs gml.printer hashtables io math.parser ;

M: hashtable write-gml
"«Dictionary with " write assoc-size number>string write
" entries»" write ;