1 ! Copyright (C) 2008 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel assocs accessors summary ;
6 TUPLE: biassoc from to ;
8 : <biassoc> ( exemplar -- biassoc )
9 [ clone ] [ clone ] bi biassoc boa ;
11 : <bihash> ( -- biassoc )
14 M: biassoc assoc-size from>> assoc-size ;
16 M: biassoc at* from>> at* ;
18 M: biassoc value-at* to>> at* ;
20 : once-at ( value key assoc -- )
21 2dup key? [ 3drop ] [ set-at ] if ;
24 [ from>> set-at ] [ swapd to>> once-at ] 3bi ;
26 ERROR: no-biassoc-deletion ;
28 M: no-biassoc-deletion summary
29 drop "biassocs do not support deletion" ;
37 M: biassoc clear-assoc
38 [ from>> clear-assoc ] [ to>> clear-assoc ] bi ;
40 INSTANCE: biassoc assoc