diff --git a/extra/assoc-deques/assoc-deques-docs.factor b/extra/assoc-deques/assoc-deques-docs.factor deleted file mode 100644 index d8f305d51d..0000000000 --- a/extra/assoc-deques/assoc-deques-docs.factor +++ /dev/null @@ -1,32 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: help.markup help.syntax io.streams.string ; -IN: assoc-deques - -HELP: -{ $description "Constructs a new " { $link assoc-deque } " from two existing data structures." } ; - -HELP: -{ $values - - { "unique-heap" assoc-deque } } -{ $description "Creates a new " { $link assoc-deque } " where the assoc is a hashtable and the deque is a max-heap." } ; - -HELP: -{ $values - - { "unique-heap" assoc-deque } } -{ $description "Creates a new " { $link assoc-deque } " where the assoc is a hashtable and the deque is a min-heap." } ; - -HELP: assoc-deque -{ $description "A data structure containing an assoc and a deque to get certain properties with better time constraints at the expense of more space and complexity. For instance, a hashtable and a heap can be combined into one assoc-deque to get a sorted data structure with O(1) lookup. Operations on assoc-deques should update both the assoc and the deque." } ; - -ARTICLE: "assoc-deques" "Associative deques" -"The " { $vocab-link "assoc-deques" } " vocabulary combines exists to synthesize data structures with better time properties than either of the two component data structures alone." $nl -"Associative deque constructor:" -{ $subsection } -"Unique heaps:" -{ $subsection } -{ $subsection } ; - -ABOUT: "assoc-deques" diff --git a/extra/assoc-deques/assoc-deques.factor b/extra/assoc-deques/assoc-deques.factor deleted file mode 100644 index a23e632b8b..0000000000 --- a/extra/assoc-deques/assoc-deques.factor +++ /dev/null @@ -1,31 +0,0 @@ -! Copyright (C) 2008 Doug Coleman. -! See http://factorcode.org/license.txt for BSD license. -USING: accessors assocs deques hashtables heaps kernel ; -IN: assoc-deques - -TUPLE: assoc-deque assoc deque ; - -C: assoc-deque - -: ( -- unique-heap ) - H{ } clone ; - -: ( -- unique-heap ) - H{ } clone ; - -M: assoc-deque heap-push* ( value key assoc-deque -- entry ) - pick over assoc>> key? [ - 3drop f - ] [ - [ assoc>> swapd set-at ] [ deque>> heap-push* ] 3bi - ] if ; - -M: assoc-deque heap-pop ( assoc-deque -- value key ) - [ deque>> heap-pop ] keep - [ over ] dip assoc>> delete-at ; - -M: assoc-deque heap-peek ( assoc-deque -- value key ) - deque>> heap-peek ; - -M: assoc-deque heap-empty? ( assoc-deque -- value key ) - deque>> heap-empty? ; diff --git a/extra/assoc-heaps/assoc-heaps-docs.factor b/extra/assoc-heaps/assoc-heaps-docs.factor new file mode 100644 index 0000000000..6a80bcc6c6 --- /dev/null +++ b/extra/assoc-heaps/assoc-heaps-docs.factor @@ -0,0 +1,32 @@ +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: help.markup help.syntax io.streams.string ; +IN: assoc-heaps + +HELP: +{ $description "Constructs a new " { $link assoc-heap } " from two existing data structures." } ; + +HELP: +{ $values + + { "unique-heap" assoc-heap } } +{ $description "Creates a new " { $link assoc-heap } " where the assoc is a hashtable and the heap is a max-heap." } ; + +HELP: +{ $values + + { "unique-heap" assoc-heap } } +{ $description "Creates a new " { $link assoc-heap } " where the assoc is a hashtable and the heap is a min-heap." } ; + +HELP: assoc-heap +{ $description "A data structure containing an assoc and a heap to get certain properties with better time constraints at the expense of more space and complexity. For instance, a hashtable and a heap can be combined into one assoc-heap to get a sorted data structure with O(1) lookup. Operations on assoc-heap should update both the assoc and the heap." } ; + +ARTICLE: "assoc-heaps" "Associative heaps" +"The " { $vocab-link "assoc-heaps" } " vocabulary combines exists to synthesize data structures with better time properties than either of the two component data structures alone." $nl +"Associative heap constructor:" +{ $subsection } +"Unique heaps:" +{ $subsection } +{ $subsection } ; + +ABOUT: "assoc-heaps" diff --git a/extra/assoc-deques/assoc-deques-tests.factor b/extra/assoc-heaps/assoc-heaps-tests.factor similarity index 62% rename from extra/assoc-deques/assoc-deques-tests.factor rename to extra/assoc-heaps/assoc-heaps-tests.factor index fe9d8840bc..6ea3fe14a4 100644 --- a/extra/assoc-deques/assoc-deques-tests.factor +++ b/extra/assoc-heaps/assoc-heaps-tests.factor @@ -1,4 +1,4 @@ ! Copyright (C) 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. -USING: tools.test assoc-deques ; -IN: assoc-deques.tests +USING: tools.test assoc-heaps ; +IN: assoc-heaps.tests diff --git a/extra/assoc-heaps/assoc-heaps.factor b/extra/assoc-heaps/assoc-heaps.factor new file mode 100644 index 0000000000..d2154002b9 --- /dev/null +++ b/extra/assoc-heaps/assoc-heaps.factor @@ -0,0 +1,31 @@ +! Copyright (C) 2008 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors assocs hashtables heaps kernel ; +IN: assoc-heaps + +TUPLE: assoc-heap assoc heap ; + +C: assoc-heap + +: ( -- unique-heap ) + H{ } clone ; + +: ( -- unique-heap ) + H{ } clone ; + +M: assoc-heap heap-push* ( value key assoc-heap -- entry ) + pick over assoc>> key? [ + 3drop f + ] [ + [ assoc>> swapd set-at ] [ heap>> heap-push* ] 3bi + ] if ; + +M: assoc-heap heap-pop ( assoc-heap -- value key ) + [ heap>> heap-pop ] keep + [ over ] dip assoc>> delete-at ; + +M: assoc-heap heap-peek ( assoc-heap -- value key ) + heap>> heap-peek ; + +M: assoc-heap heap-empty? ( assoc-heap -- value key ) + heap>> heap-empty? ; diff --git a/extra/assoc-deques/authors.txt b/extra/assoc-heaps/authors.txt similarity index 100% rename from extra/assoc-deques/authors.txt rename to extra/assoc-heaps/authors.txt diff --git a/extra/spider/spider.factor b/extra/spider/spider.factor index 8f60a0d521..7b84f8e16a 100644 --- a/extra/spider/spider.factor +++ b/extra/spider/spider.factor @@ -3,7 +3,7 @@ USING: accessors fry html.parser html.parser.analyzer http.client kernel tools.time sets assocs sequences concurrency.combinators io threads namespaces math multiline -heaps math.parser inspector urls assoc-deques logging +heaps math.parser inspector urls assoc-heaps logging combinators.short-circuit continuations calendar prettyprint ; IN: spider