set-at ( value key assoc -- ) (original) (raw)
set-at ( value key assoc -- )
Factor handbook » The language » Collections » Associative mapping operations » Associative mapping protocol
Prev: | >alist ( assoc -- newassoc ) |
---|---|
Next: | delete-at ( key assoc -- ) |
Vocabulary
assocs
Inputs
value | a value |
---|---|
key | a key to add |
assoc | an assoc |
Outputs
None
Generic word contract
Stores the key/value pair into the assoc.
Side effects
Modifies assoc
Definition
GENERIC: set-at ( value key assoc -- )
Methods
USING: accessors arrays assocs kernel sequences vectors xml.data
;
M: attrs set-at
2dup attr@ nip
[ 2nip set-second ] [
[ assure-name swap 2array ] dip [ alist>> ?push ] keep
alist<<
] if* ;
USING: accessors assocs kernel trees.avl trees.avl.private
trees.private ;
M: avl set-at
[ avl-set nip swap ] change-root swap [ dup inc-count ] when
drop ;
USING: accessors assocs biassocs kernel ;
M: biassoc set-at
[ from>> set-at ] [ swapd to>> set-at-once ] 3bi ;
USING: accessors assocs cache cache.private destructors kernel ;
M: cache-assoc set-at
check-disposed [ ] 2dip assoc>> set-at ;
USING: accessors assocs sequences ;
M: enumerated set-at seq>> set-nth ; inline
USING: assocs env environment kernel ;
M: env set-at drop set-os-env ;
USING: accessors assocs deques generic kernel
linked-assocs.private lru-cache math sequences.private ;
M: fifo-cache set-at
[ M\ fifo-cache set-at (call-next-method) ] keep
dup max-size>> [
over assoc>> assoc-size < [
[ dlist>> pop-front first-unsafe ] [ assoc>> ]
[ dlist>> ] tri (delete-at)
] [ drop ] if
] [ drop ] if* ;
USING: accessors assocs namespaces.private ;
M: global-hashtable set-at box-at value<< ; inline
USING: assocs hashtables hashtables.private kernel ;
M: hashtable set-at dup ?grow-hash (set-at) ;
USING: assocs kernel xmode.keyword-map ;
M: keyword-map set-at
[ handle-case set-at ] [ invalid-no-word-sep ] bi ;
USING: accessors assocs deques generic kernel
linked-assocs.private lru-cache math sequences.private ;
M: lifo-cache set-at
dup max-size>> [
over assoc>> assoc-size <= [
dup
[ dlist>> pop-back first-unsafe ] [ assoc>> ]
[ dlist>> ] tri (delete-at)
] when
] when* M\ lifo-cache set-at (call-next-method) ;
USING: accessors assocs kernel linked-assocs
linked-assocs.private ;
M: linked-assoc set-at
[ assoc>> ] [ dlist>> ] bi
[ 2over key? [ 3dup (delete-at) ] when nip add-to-dlist ]
curry [ set-at ] 2bi ;
USING: accessors assocs deques generic kernel
linked-assocs.private lru-cache math sequences.private ;
M: lru-cache set-at
[ M\ lru-cache set-at (call-next-method) ] keep
dup max-size>> [
over assoc>> assoc-size < [
[ dlist>> pop-front first-unsafe ] [ assoc>> ]
[ dlist>> ] tri (delete-at)
] [ drop ] if
] [ drop ] if* ;
USING: accessors assocs kernel mirrors slots slots.private ;
M: mirror set-at
[ object-slots slot-named check-set-slot ] [ object>> ] bi
swap set-slot ;
USING: assocs sequences sequences.n-based
sequences.n-based.private ;
M: n-based-assoc set-at n-based@ set-nth ;
USING: assocs classes.tuple named-tuples ;
M: named-tuple set-at set-slot-named ;
USING: accessors assocs hashtables kernel pairs ;
M: pair set-at
[ value<< ] [
[ set-at ] [ [ associate ] dip swap >>hash drop ]
if-hash
] if-key ; inline
USING: assocs quadtrees quadtrees.private ;
M: redis set-at [ redis-set ] with-redis ;
USING: arrays assocs assocs.private kernel sequences ;
M: sequence set-at
2dup search-alist
[ 2nip set-second ] [ drop [ swap 2array ] dip push ] if ;
USING: accessors assocs kernel trees.splay trees.splay.private ;
M: splay set-at dup root>> [ set-splay ] [ new-root ] if ;
USING: accessors arrays assocs classes.struct.prettyprint
combinators kernel sequences ;
M: struct-mirror set-at
object>> {
{ [ over "underlying" = ] [ 3drop ] }
{ [ over array? ] [ swap first set-struct-slot ] }
[ 3drop ]
} cond ;
USING: accessors assocs kernel xml.data ;
M: tag set-at [ attrs>> ] call \ set-at execute ;
USING: accessors assocs kernel sequences serialize
tokyo.abstractdb tokyo.alien.tcadb ;
M: tokyo-abstractdb set-at
handle>> spin [ object>bytes dup length ] bi@ tcadbput drop
;
USING: accessors assocs kernel sequences serialize
tokyo.alien.tcrdb tokyo.remotedb ;
M: tokyo-remotedb set-at
handle>> spin [ object>bytes dup length ] bi@ tcrdbput drop
;
USING: accessors assocs kernel trees trees.private ;
M: tree set-at
[ [ node-set ] [ swap t ] if* swap ] change-root swap
[ dup inc-count ] when drop ;
USING: assocs hashtables.wrapped hashtables.wrapped.private ;