1 ! Copyright (C) 2013 John Benediktsson.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors hash-sets hash-sets.wrapped kernel parser
4 sequences sets sets.private vocabs.loader ;
7 TUPLE: identity-wrapper < wrapped-key identity-hashcode ;
9 : <identity-wrapper> ( wrapped-key -- identity-wrapper )
10 dup identity-hashcode identity-wrapper boa ; inline
12 M: identity-wrapper equal?
13 over identity-wrapper?
14 [ [ underlying>> ] bi@ eq? ]
15 [ 2drop f ] if ; inline
17 M: identity-wrapper hashcode* nip identity-hashcode>> ; inline
19 TUPLE: identity-hash-set < wrapped-hash-set ;
21 : <identity-hash-set> ( n -- ihash-set )
22 <hash-set> identity-hash-set boa ; inline
24 M: identity-hash-set wrap-key drop <identity-wrapper> ;
26 M: identity-hash-set clone
27 underlying>> clone identity-hash-set boa ; inline
29 : >identity-hash-set ( members -- ihash-set )
30 [ <identity-wrapper> ] map >hash-set identity-hash-set boa ; inline
32 M: identity-hash-set set-like
33 drop dup identity-hash-set? [ ?members >identity-hash-set ] unless ; inline
35 SYNTAX: IHS{ \ } [ >identity-hash-set ] parse-literal ;
37 { "hash-sets.identity" "prettyprint" } "hash-sets.identity.prettyprint" require-when