]> gitweb.factorcode.org Git - factor.git/blob - basis/dlists/dlists-docs.factor
Fix permission bits
[factor.git] / basis / dlists / dlists-docs.factor
1 USING: help.markup help.syntax kernel quotations
2 deques ;
3 IN: dlists
4
5 ARTICLE: "dlists" "Double-linked lists"
6 "A double-linked list is the canonical implementation of a " { $link deque } "."
7 $nl
8 "Double-linked lists form a class:"
9 { $subsection dlist }
10 { $subsection dlist? }
11 "Constructing a double-linked list:"
12 { $subsection <dlist> }
13 "Double-linked lists support all the operations of the deque protocol (" { $link "deques" } ") as well as the following."
14 $nl
15 "Iterating over elements:"
16 { $subsection dlist-each }
17 { $subsection dlist-find }
18 { $subsection dlist-contains? }
19 "Deleting a node matching a predicate:"
20 { $subsection delete-node-if* }
21 { $subsection delete-node-if } ;
22
23 ABOUT: "dlists"
24
25 HELP: dlist-find
26 { $values { "dlist" { $link dlist } } { "quot" quotation } { "obj/f" "an object or " { $link f } } { "?" "a boolean" } }
27 { $description "Applies the quotation to each element of the " { $link dlist } " in turn, until it outputs a true value or the end of the " { $link dlist } " is reached.  Outputs either the object it found or " { $link f } ", and a boolean which is true if an object is found." }
28 { $notes "Returns a boolean to allow dlists to store " { $link f } "."
29     $nl
30     "This operation is O(n)."
31 } ;
32
33 HELP: dlist-contains?
34 { $values { "dlist" { $link dlist } } { "quot" quotation } { "?" "a boolean" } }
35 { $description "Just like " { $link dlist-find } " except it doesn't return the object." }
36 { $notes "This operation is O(n)." } ;
37
38 HELP: delete-node-if*
39 { $values { "dlist" { $link dlist } } { "quot" quotation } { "obj/f" "an object or " { $link f } } { "?" "a boolean" } }
40 { $description "Calls " { $link dlist-find } " on the " { $link 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 " { $link f } ", for nothing deleted." }
41 { $notes "This operation is O(n)." } ;
42
43 HELP: delete-node-if
44 { $values { "dlist" { $link dlist } } { "quot" quotation } { "obj/f" "an object or " { $link f } } }
45 { $description "Like " { $link delete-node-if* } " but cannot distinguish from deleting a node whose value is " { $link f } " or not deleting an element." }
46 { $notes "This operation is O(n)." } ;
47
48 HELP: dlist-each
49 { $values { "dlist" { $link dlist } } { "quot" quotation } }
50 { $description "Iterate a " { $link dlist } ", calling quot on each element." } ;