Double-linked lists
Factor handbook » The language » Collections

Prev:Deques
Next:Search deques


A double-linked list is the canonical implementation of a deque.

Double-linked lists form a class:
dlist

dlist? ( object -- ? )


Constructing a double-linked list:
<dlist> ( -- list )


Double-linked lists support all the operations of the deque protocol (Deques) as well as the following.

Iterating over elements:
dlist-each ( ... dlist quot: ( ... value -- ... ) -- ... )

dlist-find ( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f ? )

dlist-filter ( ... dlist quot: ( ... value -- ... ? ) -- ... dlist' )

dlist-any? ( ... dlist quot: ( ... value -- ... ? ) -- ... ? )


Deleting a node matching a predicate:
delete-node-if* ( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f ? )

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


Search deque implementation:
<hashed-dlist> ( -- search-deque )