delete-node-if* ( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f ? )
Factor handbook » The language » Collections » Double-linked lists

Prev:dlist-any? ( ... dlist quot: ( ... value -- ... ? ) -- ... ? )
Next:delete-node-if ( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f )


Vocabulary
dlists

Inputs
dlistdlist
quota quotation


Outputs
obj/fan object or f
?a boolean


Word description
Calls dlist-find on the dlist and deletes the node returned, if any. Returns the value of the deleted node and a boolean to allow the deleted value to distinguished from f, for nothing deleted.

Notes
This operation is O(n).

Definition


: delete-node-if*
( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f ? )
dupd dlist-find-node [
dup
[ [ swap delete-node ] keep obj>> t ] [ 2drop f f ] if
] [ drop f f ] if* ; inline