From 7e098265ef01ab95416946f9903ccdd982495b04 Mon Sep 17 00:00:00 2001 From: Daniel Ehrenberg Date: Thu, 21 Aug 2008 22:11:28 +0200 Subject: [PATCH] Final changes for deques rename --- basis/dequeues/authors.txt | 1 - basis/dequeues/dequeues-docs.factor | 89 ------------------- basis/dequeues/dequeues.factor | 43 --------- basis/dequeues/summary.txt | 1 - basis/dequeues/tags.txt | 1 - basis/persistent/deques/deques-docs.factor | 30 +++---- basis/search-dequeues/authors.txt | 1 - .../search-dequeues-docs.factor | 21 ----- .../search-dequeues-tests.factor | 35 -------- basis/search-dequeues/search-dequeues.factor | 53 ----------- basis/search-dequeues/summary.txt | 1 - basis/search-dequeues/tags.txt | 1 - 12 files changed, 15 insertions(+), 262 deletions(-) delete mode 100644 basis/dequeues/authors.txt delete mode 100644 basis/dequeues/dequeues-docs.factor delete mode 100644 basis/dequeues/dequeues.factor delete mode 100644 basis/dequeues/summary.txt delete mode 100644 basis/dequeues/tags.txt delete mode 100644 basis/search-dequeues/authors.txt delete mode 100644 basis/search-dequeues/search-dequeues-docs.factor delete mode 100644 basis/search-dequeues/search-dequeues-tests.factor delete mode 100644 basis/search-dequeues/search-dequeues.factor delete mode 100644 basis/search-dequeues/summary.txt delete mode 100644 basis/search-dequeues/tags.txt diff --git a/basis/dequeues/authors.txt b/basis/dequeues/authors.txt deleted file mode 100644 index 1901f27a24..0000000000 --- a/basis/dequeues/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/basis/dequeues/dequeues-docs.factor b/basis/dequeues/dequeues-docs.factor deleted file mode 100644 index 25cc969ff2..0000000000 --- a/basis/dequeues/dequeues-docs.factor +++ /dev/null @@ -1,89 +0,0 @@ -IN: dequeues -USING: help.markup help.syntax kernel ; - -ARTICLE: "dequeues" "Dequeues" -"A dequeue is a data structure with constant-time insertion and removal of elements at both ends. Dequeue operations are defined in the " { $vocab-link "dequeues" } " vocabulary." -$nl -"Dequeues must be instances of a mixin class:" -{ $subsection dequeue } -"Dequeues must implement a protocol." -$nl -"Querying the dequeue:" -{ $subsection peek-front } -{ $subsection peek-back } -{ $subsection dequeue-length } -{ $subsection dequeue-member? } -"Adding and removing elements:" -{ $subsection push-front* } -{ $subsection push-back* } -{ $subsection pop-front* } -{ $subsection pop-back* } -{ $subsection clear-dequeue } -"Working with node objects output by " { $link push-front* } " and " { $link push-back* } ":" -{ $subsection delete-node } -{ $subsection node-value } -"Utility operations built in terms of the above:" -{ $subsection dequeue-empty? } -{ $subsection push-front } -{ $subsection push-all-front } -{ $subsection push-back } -{ $subsection push-all-back } -{ $subsection pop-front } -{ $subsection pop-back } -{ $subsection slurp-dequeue } -"When using a dequeue as a queue, the convention is to queue elements with " { $link push-front } " and dequeue them with " { $link pop-back } "." ; - -ABOUT: "dequeues" - -HELP: dequeue-empty? -{ $values { "dequeue" { $link dequeue } } { "?" "a boolean" } } -{ $description "Returns true if a dequeue is empty." } -{ $notes "This operation is O(1)." } ; - -HELP: push-front -{ $values { "obj" object } { "dequeue" dequeue } } -{ $description "Push the object onto the front of the dequeue." } -{ $notes "This operation is O(1)." } ; - -HELP: push-front* -{ $values { "obj" object } { "dequeue" dequeue } { "node" "a node" } } -{ $description "Push the object onto the front of the dequeue and return the newly created node." } -{ $notes "This operation is O(1)." } ; - -HELP: push-back -{ $values { "obj" object } { "dequeue" dequeue } } -{ $description "Push the object onto the back of the dequeue." } -{ $notes "This operation is O(1)." } ; - -HELP: push-back* -{ $values { "obj" object } { "dequeue" dequeue } { "node" "a node" } } -{ $description "Push the object onto the back of the dequeue and return the newly created node." } -{ $notes "This operation is O(1)." } ; - -HELP: peek-front -{ $values { "dequeue" dequeue } { "obj" object } } -{ $description "Returns the object at the front of the dequeue." } ; - -HELP: pop-front -{ $values { "dequeue" dequeue } { "obj" object } } -{ $description "Pop the object off the front of the dequeue and return the object." } -{ $notes "This operation is O(1)." } ; - -HELP: pop-front* -{ $values { "dequeue" dequeue } } -{ $description "Pop the object off the front of the dequeue." } -{ $notes "This operation is O(1)." } ; - -HELP: peek-back -{ $values { "dequeue" dequeue } { "obj" object } } -{ $description "Returns the object at the back of the dequeue." } ; - -HELP: pop-back -{ $values { "dequeue" dequeue } { "obj" object } } -{ $description "Pop the object off the back of the dequeue and return the object." } -{ $notes "This operation is O(1)." } ; - -HELP: pop-back* -{ $values { "dequeue" dequeue } } -{ $description "Pop the object off the back of the dequeue." } -{ $notes "This operation is O(1)." } ; diff --git a/basis/dequeues/dequeues.factor b/basis/dequeues/dequeues.factor deleted file mode 100644 index ae55c57fe5..0000000000 --- a/basis/dequeues/dequeues.factor +++ /dev/null @@ -1,43 +0,0 @@ -! Copyright (C) 2008 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: kernel sequences math ; -IN: dequeues - -GENERIC: push-front* ( obj dequeue -- node ) -GENERIC: push-back* ( obj dequeue -- node ) -GENERIC: peek-front ( dequeue -- obj ) -GENERIC: peek-back ( dequeue -- obj ) -GENERIC: pop-front* ( dequeue -- ) -GENERIC: pop-back* ( dequeue -- ) -GENERIC: delete-node ( node dequeue -- ) -GENERIC: dequeue-length ( dequeue -- n ) -GENERIC: dequeue-member? ( value dequeue -- ? ) -GENERIC: clear-dequeue ( dequeue -- ) -GENERIC: node-value ( node -- value ) - -: dequeue-empty? ( dequeue -- ? ) - dequeue-length zero? ; - -: push-front ( obj dequeue -- ) - push-front* drop ; - -: push-all-front ( seq dequeue -- ) - [ push-front ] curry each ; - -: push-back ( obj dequeue -- ) - push-back* drop ; - -: push-all-back ( seq dequeue -- ) - [ push-back ] curry each ; - -: pop-front ( dequeue -- obj ) - [ peek-front ] [ pop-front* ] bi ; - -: pop-back ( dequeue -- obj ) - [ peek-back ] [ pop-back* ] bi ; - -: slurp-dequeue ( dequeue quot -- ) - [ drop [ dequeue-empty? not ] curry ] - [ [ pop-back ] prepose curry ] 2bi [ ] while ; inline - -MIXIN: dequeue diff --git a/basis/dequeues/summary.txt b/basis/dequeues/summary.txt deleted file mode 100644 index 2f348ebb05..0000000000 --- a/basis/dequeues/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Double-ended queue protocol and common operations diff --git a/basis/dequeues/tags.txt b/basis/dequeues/tags.txt deleted file mode 100644 index 42d711b32b..0000000000 --- a/basis/dequeues/tags.txt +++ /dev/null @@ -1 +0,0 @@ -collections diff --git a/basis/persistent/deques/deques-docs.factor b/basis/persistent/deques/deques-docs.factor index 56ee46a6a9..43018bed16 100644 --- a/basis/persistent/deques/deques-docs.factor +++ b/basis/persistent/deques/deques-docs.factor @@ -2,7 +2,7 @@ USING: help.markup help.syntax kernel sequences ; IN: persistent.deques ARTICLE: "persistent.deques" "Persistent deques" -"A deque is a data structure that can be used as both a queue and a stack. That is, there are two ends, the left and the right, and values can be pushed onto and popped off of both ends. These operations take O(1) amortized time and space in a normal usage pattern." +"A deque is a data structure that can be used as both a queue and a stack. That is, there are two ends, the front and the back, and values can be pushed onto and popped off of both ends. These operations take O(1) amortized time and space in a normal usage pattern." $nl "This vocabulary provides a deque implementation which is persistent and purely functional: old versions of deques are not modified by operations. Instead, each push and pop operation creates a new deque based off the old one." $nl @@ -14,10 +14,10 @@ $nl "To test if a deque is empty:" { $subsection deque-empty? } "To manipulate deques:" -{ $subsection push-left } -{ $subsection push-right } -{ $subsection pop-left } -{ $subsection pop-right } +{ $subsection push-front } +{ $subsection push-back } +{ $subsection pop-front } +{ $subsection pop-back } { $subsection deque>sequence } ; HELP: deque @@ -29,28 +29,28 @@ HELP: HELP: sequence>deque { $values { "sequence" sequence } { "deque" deque } } -{ $description "Given a sequence, creates a deque containing those elements in the order such that the beginning of the sequence is on the left and the end is on the right." } ; +{ $description "Given a sequence, creates a deque containing those elements in the order such that the beginning of the sequence is on the front and the end is on the back." } ; HELP: deque>sequence { $values { "deque" deque } { "sequence" sequence } } -{ $description "Given a deque, creates a sequence containing those elements, such that the left side of the deque is the beginning of the sequence." } ; +{ $description "Given a deque, creates a sequence containing those elements, such that the front side of the deque is the beginning of the sequence." } ; HELP: deque-empty? { $values { "deque" deque } { "?" "t/f" } } { $description "Returns true if the deque is empty. This takes constant time." } ; -HELP: push-left +HELP: push-front { $values { "deque" deque } { "item" object } { "newdeque" deque } } -{ $description "Creates a new deque with the given object pushed onto the left side. This takes constant time." } ; +{ $description "Creates a new deque with the given object pushed onto the front side. This takes constant time." } ; -HELP: push-right +HELP: push-back { $values { "deque" deque } { "item" object } { "newdeque" deque } } -{ $description "Creates a new deque with the given object pushed onto the right side. This takes constant time." } ; +{ $description "Creates a new deque with the given object pushed onto the back side. This takes constant time." } ; -HELP: pop-left +HELP: pop-front { $values { "deque" object } { "item" object } { "newdeque" deque } } -{ $description "Creates a new deque with the leftmost item removed. This takes amortized constant time with single-threaded access." } ; +{ $description "Creates a new deque with the frontmost item removed. This takes amortized constant time with single-threaded access." } ; -HELP: pop-right +HELP: pop-back { $values { "deque" object } { "item" object } { "newdeque" deque } } -{ $description "Creates a new deque with the rightmost item removed. This takes amortized constant time with single-threaded access." } ; +{ $description "Creates a new deque with the backmost item removed. This takes amortized constant time with single-threaded access." } ; diff --git a/basis/search-dequeues/authors.txt b/basis/search-dequeues/authors.txt deleted file mode 100644 index 1901f27a24..0000000000 --- a/basis/search-dequeues/authors.txt +++ /dev/null @@ -1 +0,0 @@ -Slava Pestov diff --git a/basis/search-dequeues/search-dequeues-docs.factor b/basis/search-dequeues/search-dequeues-docs.factor deleted file mode 100644 index de9e9f0084..0000000000 --- a/basis/search-dequeues/search-dequeues-docs.factor +++ /dev/null @@ -1,21 +0,0 @@ -IN: search-dequeues -USING: help.markup help.syntax kernel dlists hashtables -dequeues assocs ; - -ARTICLE: "search-dequeues" "Search dequeues" -"A search dequeue is a data structure with constant-time insertion and removal of elements at both ends, and constant-time membership tests. Inserting an element more than once has no effect. Search dequeues implement all dequeue operations in terms of an underlying dequeue, and membership testing with " { $link dequeue-member? } " is implemented with an underlying assoc. Search dequeues are defined in the " { $vocab-link "search-dequeues" } " vocabulary." -$nl -"Creating a search dequeue:" -{ $subsection } -"Default implementation:" -{ $subsection } ; - -ABOUT: "search-dequeues" - -HELP: ( assoc dequeue -- search-dequeue ) -{ $values { "assoc" assoc } { "dequeue" dequeue } { "search-dequeue" search-dequeue } } -{ $description "Creates a new " { $link search-dequeue } "." } ; - -HELP: ( -- search-dequeue ) -{ $values { "search-dequeue" search-dequeue } } -{ $description "Creates a new " { $link search-dequeue } " backed by a " { $link dlist } ", with a " { $link hashtable } " for fast membership tests." } ; diff --git a/basis/search-dequeues/search-dequeues-tests.factor b/basis/search-dequeues/search-dequeues-tests.factor deleted file mode 100644 index acf929de46..0000000000 --- a/basis/search-dequeues/search-dequeues-tests.factor +++ /dev/null @@ -1,35 +0,0 @@ -IN: search-dequeues.tests -USING: search-dequeues tools.test namespaces -kernel sequences words dequeues vocabs ; - - "h" set - -[ t ] [ "h" get dequeue-empty? ] unit-test - -[ ] [ 3 "h" get push-front* "1" set ] unit-test -[ ] [ 1 "h" get push-front ] unit-test -[ ] [ 3 "h" get push-front* "2" set ] unit-test -[ ] [ 3 "h" get push-front* "3" set ] unit-test -[ ] [ 7 "h" get push-front ] unit-test - -[ t ] [ "1" get "2" get eq? ] unit-test -[ t ] [ "2" get "3" get eq? ] unit-test - -[ 3 ] [ "h" get dequeue-length ] unit-test -[ t ] [ 7 "h" get dequeue-member? ] unit-test - -[ 3 ] [ "1" get node-value ] unit-test -[ ] [ "1" get "h" get delete-node ] unit-test - -[ 2 ] [ "h" get dequeue-length ] unit-test -[ 1 ] [ "h" get pop-back ] unit-test -[ 7 ] [ "h" get pop-back ] unit-test - -[ f ] [ 7 "h" get dequeue-member? ] unit-test - -[ ] [ - - [ all-words swap [ push-front ] curry each ] - [ [ drop ] slurp-dequeue ] - bi -] unit-test diff --git a/basis/search-dequeues/search-dequeues.factor b/basis/search-dequeues/search-dequeues.factor deleted file mode 100644 index 87c997a3ac..0000000000 --- a/basis/search-dequeues/search-dequeues.factor +++ /dev/null @@ -1,53 +0,0 @@ -! Copyright (C) 2008 Slava Pestov. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors kernel assocs dequeues dlists hashtables ; -IN: search-dequeues - -TUPLE: search-dequeue assoc dequeue ; - -C: search-dequeue - -: ( -- search-dequeue ) - 0 ; - -M: search-dequeue dequeue-length dequeue>> dequeue-length ; - -M: search-dequeue peek-front dequeue>> peek-front ; - -M: search-dequeue peek-back dequeue>> peek-back ; - -M: search-dequeue push-front* - 2dup assoc>> at* [ 2nip ] [ - drop - [ dequeue>> push-front* ] [ assoc>> ] 2bi - [ 2drop ] [ set-at ] 3bi - ] if ; - -M: search-dequeue push-back* - 2dup assoc>> at* [ 2nip ] [ - drop - [ dequeue>> push-back* ] [ assoc>> ] 2bi - [ 2drop ] [ set-at ] 3bi - ] if ; - -M: search-dequeue pop-front* - [ [ dequeue>> peek-front ] [ assoc>> ] bi delete-at ] - [ dequeue>> pop-front* ] - bi ; - -M: search-dequeue pop-back* - [ [ dequeue>> peek-back ] [ assoc>> ] bi delete-at ] - [ dequeue>> pop-back* ] - bi ; - -M: search-dequeue delete-node - [ dequeue>> delete-node ] - [ [ node-value ] [ assoc>> ] bi* delete-at ] 2bi ; - -M: search-dequeue clear-dequeue - [ dequeue>> clear-dequeue ] [ assoc>> clear-assoc ] bi ; - -M: search-dequeue dequeue-member? - assoc>> key? ; - -INSTANCE: search-dequeue dequeue diff --git a/basis/search-dequeues/summary.txt b/basis/search-dequeues/summary.txt deleted file mode 100644 index 9102bf2d58..0000000000 --- a/basis/search-dequeues/summary.txt +++ /dev/null @@ -1 +0,0 @@ -Double-ended queues with sub-linear membership testing diff --git a/basis/search-dequeues/tags.txt b/basis/search-dequeues/tags.txt deleted file mode 100644 index 42d711b32b..0000000000 --- a/basis/search-dequeues/tags.txt +++ /dev/null @@ -1 +0,0 @@ -collections