at* ( key assoc -- value/f ? )
Factor documentation > Factor handbook > The language > Collections > Associative mapping operations > Associative mapping protocol
Prev:assoc? ( object -- ? )
Next:assoc-size ( assoc -- n )


Vocabulary
assocs

Inputs and outputs
keyan object to look up in the assoc
assocan assoc
value/fthe value associated to the key, or f if the key is not present in the assoc
?a boolean indicating if the key was present


Generic word contract
Looks up the value associated with a key. The boolean flag can decide between the case of a missing value, and a value of f.

See also
at, key?, ?at, of, ?of

Definition
IN: assocs

GENERIC: at* ( key assoc -- value/f ? )


Methods
USING: assocs kernel sequences xml.data ;

M: attrs at* attr@ nip [ second t ] [ f f ] if* ;


USING: accessors assocs biassocs ;

M: biassoc at* from>> at* ; inline


USING: accessors assocs cache kernel ;

M: cache-assoc at*
assoc>> at* [ dup [ 0 >>age value>> ] when ] dip ;


USING: accessors assocs kernel sequences sequences.private ;

M: enum at*
seq>> 2dup bounds-check? [ nth-unsafe t ] [ 2drop f f ] if
; inline


USING: assocs env environment kernel ;

M: env at* drop os-env dup >boolean ;


USING: assocs kernel ;

M: f at* 2drop f f ; inline


USING: accessors assocs kernel kernel.private
namespaces.private ;

M: global-hashtable at*
boxes>> at*
[ { global-box } declare value>> dup ] [ drop f f ] if ;
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: assocs xmode.keyword-map ;

M: keyword-map at* handle-case at* ;


USING: accessors assocs kernel linked-assocs sequences.private
;

M: linked-assoc at*
assoc>> at* [ [ obj>> second-unsafe ] when ] keep ;


USING: accessors assocs kernel mirrors slots slots.private ;

M: mirror at*
[ nip object>> ] [ object-slots slot-named ] 2bi dup
[ offset>> slot t ] [ 2drop f f ] if ;


USING: assocs kernel sequences sequences.n-based
sequences.n-based.private sequences.private ;

M: n-based-assoc at*
n-based@ 2dup bounds-check?
[ nth-unsafe t ] [ 2drop f f ] if ;


USING: accessors assocs kernel pairs ;

M: pair at*
[ value>> t ] [ [ at* ] [ 2drop f f ] if-hash ] if-key ;
inline


USING: accessors assocs kernel math persistent.hashtables
persistent.hashtables.nodes ;

M: persistent-hash at*
[ dup hashcode >fixnum ] [ root>> ] bi* (entry-at) dup
[ value>> t ] [ f ] if ;


USING: assocs quadtrees quadtrees.private ;

M: quadtree at* at-point ;


USING: assocs kernel redis ;

M: redis at* [ redis-get dup >boolean ] with-redis ;


USING: assocs assocs.private kernel sequences ;

M: sequence at* search-alist [ second t ] [ f ] if ;


USING: accessors assocs kernel trees.splay trees.splay.private
;

M: splay at*
dup root>>
[ get-splay [ dup [ value>> ] when ] dip ] [ 2drop f f ] if
;


USING: accessors alien arrays assocs classes.struct.prettyprint
combinators combinators.short-circuit kernel math sequences ;

M: struct-mirror at*
object>> {
{ [ over "underlying" = ] [ nip >c-ptr t ] }
{
[ over { [ array? ] [ length 1 >= ] } 1&& ]
[ swap first get-struct-slot ]
}
[ 2drop f f ]
} cond ;


USING: accessors alien.c-types alien.data assocs kernel
sequences serialize tokyo.abstractdb tokyo.alien.tcadb
tokyo.alien.tcutil tokyo.utils ;

M: tokyo-abstractdb at*
handle>> swap object>bytes dup length 0 int <ref> tcadbget
[ [ memory>object ] [ tcfree ] bi t ] [ f f ] if* ;


USING: accessors alien.c-types alien.data assocs kernel
sequences serialize tokyo.alien.tcrdb tokyo.alien.tcutil
tokyo.remotedb tokyo.utils ;

M: tokyo-remotedb at*
handle>> swap object>bytes dup length 0 int <ref> tcrdbget
[ [ memory>object ] [ tcfree ] bi t ] [ f f ] if* ;


USING: accessors assocs trees trees.private ;

M: tree at* root>> node-at* ;


USING: accessors assocs kernel math vlists vlists.private ;

M: valist at*
vlist>> >vlist< [ 2 - ] [ underlying>> ] bi* valist-at ;


USING: assocs hashtables.wrapped hashtables.wrapped.private ;

M: wrapped-hashtable at* wrapper@ at* ; inline