*sigh* And now DrDr is back to complaining at me about a file that I've never touched.<br><div class="gmail_extra"><br clear="all">Carl Eastlund<br>
<br><div class="gmail_quote">On Wed, Dec 5, 2012 at 9:34 AM, <span dir="ltr"><<a href="mailto:mflatt@racket-lang.org" target="_blank">mflatt@racket-lang.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
mflatt has updated `master' from 64f0273829 to a559347f4c.<br>
<a href="http://git.racket-lang.org/plt/64f0273829..a559347f4c" target="_blank">http://git.racket-lang.org/plt/64f0273829..a559347f4c</a><br>
<br>
=====[ 3 Commits ]======================================================<br>
Directory summary:<br>
99.1% collects/syntax-color/<br>
<br>
~~~~~~~~~~<br>
<br>
62019bb Matthew Flatt <<a href="mailto:mflatt@racket-lang.org" target="_blank">mflatt@racket-lang.org</a>> 2012-12-05 08:25<br>
:<br>
| raco setup: flush loaded "info-domain" when info is updated<br>
|<br>
| Fixes problems updating user-specific documentation on a<br>
| package install, for example.<br>
:<br>
M collects/setup/setup-unit.rkt | 4 +++-<br>
<br>
~~~~~~~~~~<br>
<br>
8e5a42b Matthew Flatt <<a href="mailto:mflatt@racket-lang.org" target="_blank">mflatt@racket-lang.org</a>> 2012-12-05 08:32<br>
:<br>
| remove docs for removed library<br>
:<br>
D collects/syntax-color/augmented-red-black.scrbl<br>
<br>
~~~~~~~~~~<br>
<br>
a559347 Matthew Flatt <<a href="mailto:mflatt@racket-lang.org" target="_blank">mflatt@racket-lang.org</a>> 2012-12-05 08:33<br>
:<br>
| remove property for removed file<br>
:<br>
M collects/meta/props | 1 -<br>
<br>
=====[ Overall Diff ]===================================================<br>
<br>
collects/meta/props<br>
~~~~~~~~~~~~~~~~~~~<br>
--- OLD/collects/meta/props<br>
+++ NEW/collects/meta/props<br>
@@ -1477,7 +1477,6 @@ path/s is either such a string or a list of them.<br>
"collects/tests/units" responsible (sstrickl)<br>
"collects/tests/unstable" responsible (jay samth cce ryanc)<br>
"collects/tests/unstable/automata" responsible (jay)<br>
-"collects/tests/unstable/cat.rkt" responsible (ryanc)<br>
"collects/tests/unstable/list.rkt" responsible (jay)<br>
"collects/tests/unstable/logging.rkt" responsible (stamourv)<br>
"collects/tests/unstable/srcloc.rktl" responsible (cce)<br>
<br>
collects/setup/setup-unit.rkt<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/collects/setup/setup-unit.rkt<br>
+++ NEW/collects/setup/setup-unit.rkt<br>
@@ -970,7 +970,9 @@<br>
(with-output-to-file p #:exists 'truncate/replace<br>
(lambda ()<br>
(write (hash-map ht cons))<br>
- (newline))))))))<br>
+ (newline)))))))<br>
+ ;; Flush cached state in the current namespace:<br>
+ (reset-relevant-directories-state!))<br>
<br>
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
;; Docs ;;<br>
<br>
collects/syntax-color/augmented-red-black.scrbl<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
--- OLD/collects/syntax-color/augmented-red-black.scrbl<br>
+++ /dev/null<br>
@@ -1,807 +0,0 @@<br>
-#lang scribble/doc<br>
-@(require scribble/manual<br>
- scribble/eval<br>
- (for-label syntax-color/private/augmented-red-black<br>
- racket/base<br>
- racket/string))<br>
-<br>
-@(define my-eval (make-base-eval))<br>
-@(my-eval '(require syntax-color/private/augmented-red-black racket/string))<br>
-<br>
-@title{Augmented Red-Black Trees}<br>
-@author+email["Danny Yoo" "<a href="mailto:dyoo@hashcollision.org" target="_blank">dyoo@hashcollision.org</a>"]<br>
-<br>
-<br>
-@defmodule[syntax-color/private/augmented-red-black]<br>
-<br>
-This is an implementation of an augmented red-black tree that extends the nodes<br>
-of a basic red-black tree with attached metadata at every node. The metadata<br>
-at a node should be a function of the data of the current node and the left and<br>
-right children.<br>
-<br>
-One intended usage case of this structure is to maintain an ordered sequence of<br>
-items, where each item has an internal length. Given such a sequence, we want<br>
-to support quick lookup by position and in-place insertions and deletions. We<br>
-also want to support the catenation and splitting of sequences.<br>
-<br>
-For example:<br>
-<br>
-@interaction[#:eval my-eval<br>
-@code:comment{Here, the metadata represents the length of the contents}<br>
-@code:comment{of the entire subtree:}<br>
-(define (size-of-data data)<br>
- (string-length data))<br>
-(define (new-catenated-string-tree)<br>
- (new-tree #:metadata-f (lambda (data left right)<br>
- (+ (size-of-data data)<br>
- (or (node-metadata left) 0)<br>
- (or (node-metadata right) 0)))))<br>
-(define a-tree (new-catenated-string-tree))<br>
-(for ([w (in-list '("This" " " "is" " " "a" " " "test"))])<br>
- (insert-last/data! a-tree w))<br>
-<br>
-@code:comment{Assuming the metadata is correct at every node, we can search}<br>
-@code:comment{for a node by its "position" by using the metadata:}<br>
-(define (search a-tree offset)<br>
- (let loop ([offset offset] [a-node (tree-root a-tree)])<br>
- (cond<br>
- [(nil-node? a-node) nil]<br>
- [else<br>
- (define left (node-left a-node))<br>
- (define left-subtree-width (or (node-metadata left) 0))<br>
- (cond [(< offset left-subtree-width)<br>
- (loop offset left)]<br>
- [else<br>
- (define residual-offset (- offset left-subtree-width))<br>
- (define len (size-of-data (node-data a-node)))<br>
- (cond<br>
- [(< residual-offset len)<br>
- a-node]<br>
- [else<br>
- (loop (- residual-offset len)<br>
- (node-right a-node))])])])))<br>
-@code:comment{Now we can search:}<br>
-(node-data (search a-tree 0))<br>
-(node-data (search a-tree 10))<br>
-(define at-test-node (search a-tree 10))<br>
-@code:comment{We can also insert within the tree,}<br>
-(insert-before/data! a-tree at-test-node "small")<br>
-(tree-items a-tree)<br>
-@code:comment{and split at the node holding "small".}<br>
-(define at-small-node (search a-tree 10))<br>
-(define-values (left-side right-side) (split! a-tree at-small-node))<br>
-(tree-items left-side)<br>
-(tree-items right-side)<br>
-(define joined-tree (join! left-side right-side))<br>
-(tree-items joined-tree)<br>
-]<br>
-<br>
-<br>
-The interpretation of the metadata is up to clients. Another approprate<br>
-metadata may hold subtree @emph{size} rather than string length, in which case<br>
-the tree acts as an container where items can be found through their index:<br>
-<br>
-@interaction[#:eval my-eval<br>
-@code:comment{The definitions above depend on the value of}<br>
-@code:comment{size-of-data. Let's mutate it to be evil.}<br>
-@code:comment{(Note: don't do this in production code.)}<br>
-(set! size-of-data (lambda (data) 1))<br>
-@code:comment{And now we get a different kind of search altogether:}<br>
-(define t (new-catenated-string-tree))<br>
-(insert-last/data! t "rock")<br>
-(insert-last/data! t "scissors")<br>
-(insert-after/data! t (tree-first t) "paper")<br>
-(node-data (search t 0))<br>
-(node-data (search t 1))<br>
-(node-data (search t 2))<br>
-]<br>
-<br>
-<br>
-This augmented red-black tree implementation follows the basic outline in<br>
-@cite{clrs2009} and incorporates a few extensions suggsted in @cite{wein2005}.<br>
-As a red-black tree, the structure ensures that the tree's height is never<br>
-greater than @math{2*lg(#-of-nodes + 1)}, guaranteeing good worst-case behavior<br>
-for its operations.<br>
-<br>
-The main types of values used in the library are @emph{trees} and @emph{nodes}.<br>
-A tree has a @emph{root} node (@racket[tree-root]), and each node has holds<br>
-arbitrary @emph{data} (@racket[node-data]) and @emph{metadata}<br>
-(@racket[node-metadata]), along with a reference to the elements smaller<br>
-(@racket[node-left]) and larger (@racket[node-right]). The tree holds first<br>
-and last pointers into the structure to allow for fast access to the beginning<br>
-and end of the sequence. A distinguished @racket[nil] node lies at the leaves<br>
-of the tree.<br>
-<br>
-<br>
-<br>
-@section{API}<br>
-@declare-exporting[syntax-color/private/augmented-red-black]<br>
-<br>
-<br>
-@subsection{Data types}<br>
-<br>
-@defproc[(new-tree [#:metadata-f metadata-f #f (or/c #f (any/c node? node? . -> . any))]) tree?]{<br>
-Constructs a new tree. The tree's root is initially @racket[nil].<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-a-tree<br>
-(nil-node? (tree-root a-tree))<br>
-]<br>
-<br>
-<br>
-When provided a @racket[#:metadata-f], each node in the tree will<br>
-have an associated @racket[node-metadata] that is computed through its<br>
-@racket[node-data], @racket[node-left] and @racket[node-right].<br>
-<br>
-The @racket[#:metadata-f] must not mutate the tree as a side effect; contracts<br>
-currently do not enforce this requirement, but may in the future.}<br>
-<br>
-<br>
-<br>
-@defproc[(tree? [x any/c]) boolean?]{<br>
-Returns @racket[#t] if @racket[x] is a tree.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(tree? a-tree)<br>
-(tree? "not a tree")<br>
-(tree? (new-node '(not a tree either)))<br>
-]}<br>
-<br>
-<br>
-<br>
-@defproc[(tree-root [t tree?]) node?]{<br>
-Returns the root node of the tree @racket[t].<br>
-If the tree is empty, returns the distinguished @racket[nil] node.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(nil-node? (tree-root (new-tree)))<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "first node!"))<br>
-(insert-first! a-tree a-node)<br>
-(eq? a-node (tree-root a-tree))]<br>
-}<br>
-<br>
-<br>
-@defproc[(tree-metadata-f [t tree?]) (or/c #f (any/c node? node? . -> . any))]{<br>
-Returns the metadata-computing function for the tree @racket[t].<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(tree-metadata-f a-tree)<br>
-(define (indexed-metadata-f data left right)<br>
- (+ 1 (or (node-metadata left) 0) (or (node-metadata right) 0)))<br>
-(define another-tree (new-tree #:metadata-f indexed-metadata-f))<br>
-(tree-metadata-f another-tree)<br>
-]<br>
-<br>
-}<br>
-<br>
-<br>
-<br>
-@defproc[(tree-first [t tree?]) node?]{<br>
-Returns the first node in the tree.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(nil-node? (tree-first (new-tree)))<br>
-(define a-node (new-node "first node!"))<br>
-(define another-node (new-node "last node!"))<br>
-(insert-first! a-tree a-node)<br>
-(insert-last! a-tree another-node)<br>
-(eq? a-node (tree-first a-tree))]<br>
-}<br>
-<br>
-<br>
-@defproc[(tree-last [t tree?]) node?]{<br>
-Returns the last node in the tree.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(nil-node? (tree-first (new-tree)))<br>
-(define a-node (new-node "first node!"))<br>
-(define another-node (new-node "last node!"))<br>
-(insert-first! a-tree a-node)<br>
-(insert-last! a-tree another-node)<br>
-(eq? another-node (tree-last a-tree))]<br>
-}<br>
-<br>
-<br>
-@defproc[(new-node [data any/c]) singleton-node?]{<br>
-Constructs a new singleton node. This node can be inserted into a tree with<br>
-@racket[insert-first!], @racket[insert-last!], @racket[insert-before!], or<br>
-@racket[insert-after!], and spliced with @racket[concat!].<br>
-<br>
-@interaction[#:eval my-eval<br>
-(new-node #("a" "node"))]<br>
-}<br>
-<br>
-<br>
-@defproc[(node? [x any/c]) boolean?]{<br>
-Returns @racket[#t] if @racket[x] is a node.<br>
-@interaction[#:eval my-eval<br>
-(node? (new-node #("a" "node")))<br>
-@code:comment{Trees are not nodes: they _have_ nodes.}<br>
-(node? (new-tree))<br>
-(node? (tree-root (new-tree)))<br>
-]<br>
-}<br>
-<br>
-<br>
-@defproc[(singleton-node? [x any/c]) boolean?]{<br>
-Returns @racket[#t] if @racket[x] is a @emph{singleton node}. A singleton node<br>
-is unattached to any tree, and is not the @racket[nil] node.<br>
-@interaction[#:eval my-eval<br>
-(singleton-node? (new-node #("a" "node")))<br>
-(singleton-node? nil)<br>
-<br>
-@code:comment{Create a fresh node:}<br>
-(define a-node (new-node "about to attach"))<br>
-(singleton-node? a-node)<br>
-@code:comment{After attachment, it is no longer singleton:}<br>
-(define a-tree (new-tree))<br>
-(insert-first! a-tree a-node)<br>
-(singleton-node? a-node)<br>
-@code:comment{Operations such as delete! or split! will break}<br>
-@code:comment{off nodes as singletons again:}<br>
-(delete! a-tree a-node)<br>
-(singleton-node? a-node)<br>
-]<br>
-}<br>
-<br>
-<br>
-@defthing[nil node?]{<br>
-<br>
-The distinguished @racket[nil] node. By definition, @racket[nil] is colored<br>
-@racket['black], its @racket[node-metadata] is @racket[#f], and its<br>
-@racket[node-parent], @racket[node-left], and @racket[node-right] are pointed<br>
-to itself.}<br>
-<br>
-<br>
-@defproc[(non-nil-node? [x any/c]) boolean?]{<br>
-Returns @racket[#t] if @racket[x] is a non-nil node.<br>
-@interaction[#:eval my-eval<br>
-(non-nil-node? nil)<br>
-(non-nil-node? (new-node "I am not a number"))<br>
-]<br>
-}<br>
-<br>
-<br>
-@defproc[(nil-node? [x any/c]) boolean?]{<br>
-Returns @racket[#t] if @racket[x] is the nil node.<br>
-@interaction[#:eval my-eval<br>
-(nil-node? nil)<br>
-(nil-node? (new-node "I am not a number"))<br>
-]<br>
-}<br>
-<br>
-<br>
-@defproc[(node-data [n node?]) any/c]{<br>
-Returns the data associated to node @racket[n].<br>
-@interaction[#:eval my-eval<br>
-(define a-node (new-node "utah"))<br>
-(node-data a-node)<br>
-]<br>
-}<br>
-<br>
-@defproc[(update-node-data! [t tree?] [n node?] [v any/c]) void?]{<br>
-<br>
-Assigns the data associated to node @racket[n]. Note that this also may update<br>
-the metadata of the tree if the tree has been constructed with a<br>
-@racket[#:metadata-f].<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "utah"))<br>
-(insert-first! a-tree a-node)<br>
-(update-node-data! a-tree a-node "rhode island")<br>
-(node-data a-node)<br>
-]<br>
-}<br>
-<br>
-<br>
-<br>
-@defproc[(node-metadata [n node?]) any/c]{<br>
-Returns the width of the entire subtree at node @racket[n]. This sums the<br>
-width of the left and right child subtrees, as well as its self-width.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define (size-metadata str left right)<br>
- (+ 1<br>
- (or (node-metadata left) 0)<br>
- (or (node-metadata right) 0)))<br>
-(define a-tree (new-tree #:metadata-f size-metadata))<br>
-(insert-last/data! a-tree "berkeley")<br>
-(insert-last/data! a-tree "stanford")<br>
-(insert-last/data! a-tree "wpi")<br>
-(insert-last/data! a-tree "brown")<br>
-(insert-last/data! a-tree "utah")<br>
-@code:comment{The entire tree should have a metadata of five, the size of the tree.}<br>
-(node-metadata (tree-root a-tree))<br>
-(node-metadata (node-left (tree-root a-tree)))<br>
-(node-metadata (node-right (tree-root a-tree)))<br>
-]<br>
-}<br>
-<br>
-<br>
-<br>
-@defproc[(node-parent [n node?]) node?]{<br>
-Returns the parent of the node @racket[n].<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(insert-last/data! a-tree "bill and ted's excellent adventure")<br>
-(insert-last/data! a-tree "the matrix")<br>
-(insert-last/data! a-tree "speed")<br>
-(define p (node-parent (tree-last a-tree)))<br>
-(node-data p)]<br>
-}<br>
-<br>
-<br>
-@defproc[(node-left [n node?]) node?]{<br>
-Returns the left child of the node @racket[n].<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(insert-last/data! a-tree "bill and ted's excellent adventure")<br>
-(insert-last/data! a-tree "the matrix")<br>
-(insert-last/data! a-tree "speed")<br>
-(define p (node-left (tree-root a-tree)))<br>
-(node-data p)]<br>
-}<br>
-<br>
-<br>
-@defproc[(node-right [n node?]) node?]{<br>
-Returns the right child of the node @racket[n].<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(insert-last/data! a-tree "bill and ted's excellent adventure")<br>
-(insert-last/data! a-tree "the matrix")<br>
-(insert-last/data! a-tree "speed")<br>
-(define p (node-right (tree-root a-tree)))<br>
-(node-data p)]<br>
-}<br>
-<br>
-<br>
-<br>
-@defproc[(node-color [n node?]) (or/c 'red 'black)]{<br>
-<br>
-Returns the color of the node @racket[n]. The red-black tree structure uses<br>
-this value internally to maintain binary tree balance; most users will not need<br>
-to inspect this value.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(insert-last/data! a-tree "the color purple")<br>
-(insert-last/data! a-tree "pretty in pink")<br>
-(insert-last/data! a-tree "the thin red line")<br>
-(insert-last/data! a-tree "clockwork orange")<br>
-(insert-last/data! a-tree "fried green tomatoes")<br>
-(node-color (tree-root a-tree))<br>
-(tree-fold-inorder a-tree<br>
- (lambda (n acc)<br>
- (cons (list (node-data n) (node-color n))<br>
- acc))<br>
- '())]<br>
-}<br>
-<br>
-<br>
-@defproc[(red? [n node?]) boolean?]{<br>
-Returns @racket[#t] if node @racket[n] is red.<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(insert-last/data! a-tree "the hobbit")<br>
-(insert-last/data! a-tree "the fellowship of the ring")<br>
-(red? (tree-root a-tree))<br>
-(red? (node-right (tree-root a-tree)))<br>
-]<br>
-}<br>
-<br>
-<br>
-@defproc[(black? [n node?]) boolean?]{<br>
-Returns @racket[#t] if node @racket[n] is black.<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(insert-last/data! a-tree "the fellowship of the ring")<br>
-(insert-last/data! a-tree "the two towers")<br>
-(insert-last/data! a-tree "return of the king")<br>
-@code:comment{The root is always black.}<br>
-(black? (tree-root a-tree))<br>
-@code:comment{The tree should have towers as the root, with}<br>
-@code:comment{the fellowship and king as left and right respectively.}<br>
-(map node-data<br>
- (list (tree-root a-tree)<br>
- (node-left (tree-root a-tree))<br>
- (node-right (tree-root a-tree))))<br>
-(black? (tree-root a-tree))<br>
-(black? (node-left (tree-root a-tree)))<br>
-(black? (node-right (tree-root a-tree)))<br>
-]<br>
-}<br>
-<br>
-<br>
-@subsection{Operations}<br>
-<br>
-@defproc[(insert-first! [t tree?] [n singleton-node?]) void?]{<br>
-Adds node @racket[n] as the first element in tree @racket[t].<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "pear"))<br>
-(insert-first! a-tree a-node)<br>
-(eq? (tree-root a-tree) a-node)<br>
-]<br>
-<br>
-Note that attempting to add an attached, non-singleton node to a tree will<br>
-raise a contract error.<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "persimmon"))<br>
-(insert-first! a-tree a-node)<br>
-(insert-first! a-tree a-node)<br>
-]<br>
-}<br>
-<br>
-@defproc[(insert-last! [t tree?] [n singleton-node?]) void?]{<br>
-Adds node @racket[n] as the last element in tree @racket[t].<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "apple"))<br>
-(insert-last! a-tree a-node)<br>
-(eq? (tree-root a-tree) a-node)<br>
-]<br>
-<br>
-Note that attempting to add an attached, non-singleton node to a tree will<br>
-raise a contract error.<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "orange"))<br>
-(insert-last! a-tree a-node)<br>
-(insert-last! a-tree a-node)<br>
-]<br>
-}<br>
-<br>
-<br>
-<br>
-@defproc[(insert-before! [t tree?] [n1 node?] [n2 node?]) void?]{<br>
-Adds node @racket[n2] before node @racket[n1] in tree @racket[t]. This effectively<br>
-makes @racket[n2] the @racket[predecessor] of @racket[n1].<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "banana"))<br>
-(define b-node (new-node "mango"))<br>
-(insert-first! a-tree a-node)<br>
-(insert-before! a-tree a-node b-node)<br>
-(eq? (predecessor a-node) b-node)<br>
-(eq? (successor b-node) a-node)<br>
-]<br>
-<br>
-Note that attempting to add an attached, non-singleton node to a tree will<br>
-raise a contract error.<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "peach"))<br>
-(insert-first! a-tree a-node)<br>
-(insert-before! a-tree a-node a-node)<br>
-]<br>
-}<br>
-<br>
-<br>
-<br>
-@defproc[(insert-after! [t tree?] [n1 node?] [n2 node?]) void?]{<br>
-Adds node @racket[n2] after node @racket[n1] in tree @racket[t]. This effectively<br>
-makes @racket[n2] the @racket[successor] of @racket[n1].<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "cherry"))<br>
-(define b-node (new-node "pawpaw"))<br>
-(insert-first! a-tree a-node)<br>
-(insert-after! a-tree a-node b-node)<br>
-(eq? (successor a-node) b-node)<br>
-(eq? (predecessor b-node) a-node)<br>
-]<br>
-<br>
-Note that attempting to add an attached, non-singleton node to a tree will<br>
-raise a contract error.<br>
-@interaction[#:eval my-eval<br>
-(define a-tree (new-tree))<br>
-(define a-node (new-node "grapefruit"))<br>
-(insert-first! a-tree a-node)<br>
-(insert-after! a-tree a-node a-node)<br>
-]<br>
-}<br>
-<br>
-<br>
-<br>
-@deftogether[<br>
-(<br>
-@defproc[(insert-first/data! [t tree?] [data any/c]) void?]{}<br>
-@defproc[(insert-last/data! [t tree?] [data any/c]) void?]{}<br>
-@defproc[(insert-before/data! [t tree?] [n node?] [data any/c]) void?]{}<br>
-@defproc[(insert-after/data! [t tree?] [n node?] [data any/c]) void?]{})<br>
-]{<br>
-<br>
-For user convenience, the functions @racket[insert-first/data!],<br>
-@racket[insert-last/data!], @racket[insert-before/data!], and<br>
-@racket[insert-after/data!] have been provided. These create nodes and insert<br>
-into the tree structure the same way as @racket[insert-first!],<br>
-@racket[insert-last!], @racket[insert-before!], and @racket[insert-after!].<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define t (new-tree))<br>
-(insert-first/data! t "message in a bottle")<br>
-(insert-last/data! t "don't stand so close to me")<br>
-(insert-before/data! t (tree-first t) "everything she does is magic")<br>
-(insert-after/data! t (tree-last t) "king of pain")<br>
-(tree-items t)<br>
-]<br>
-}<br>
-<br>
-<br>
-@defproc[(delete! [t tree?] [n non-nil-node?]) void?]{<br>
-Deletes node @racket[n] from the tree @racket[t]. After deletion, @racket[n]<br>
-will become a singleton node.<br>
-@interaction[#:eval my-eval<br>
-(define t (new-tree))<br>
-(define n1 (new-node "George, George, George of the Jungle,"))<br>
-(define n2 (new-node "strong as he can be..."))<br>
-(define n3 (new-node "aaaaaaaaaaah!"))<br>
-(define n4 (new-node "watch out for that..."))<br>
-(define n5 (new-node "<thump!>"))<br>
-(define n6 (new-node "treeeeeeeeee!, "))<br>
-(for ([n (in-list (list n1 n2 n3 n4 n5 n6))])<br>
- (insert-last! t n))<br>
-(delete! t n5)<br>
-(tree-items t)<br>
-]<br>
-<br>
-Note that @racket[n] must be attached to tree @racket[t] or else will raise<br>
-a contract error:<br>
-@interaction[#:eval my-eval<br>
-(define t1 (new-tree))<br>
-(insert-first/data! t1 "tricky")<br>
-(define n (new-node "tricky"))<br>
-@code:comment{This should raise an error:}<br>
-(delete! t1 n)<br>
-]}<br>
-<br>
-<br>
-@defproc[(join! [t1 tree?] [t2 tree?]) tree?]{<br>
-Destructively joins trees @racket[t1] and @racket[t2], returning a tree that<br>
-has the contents of both. Every element in @racket[t1] is treated less than<br>
-the elements in @racket[t2].<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define t1 (new-tree))<br>
-(for ([name (in-list '(goku gohan krillin piccolo vegeta))])<br>
- (insert-last/data! t1 name))<br>
-@code:comment{Tier two characters:}<br>
-(define t2 (new-tree))<br>
-(for ([name (in-list '(yamcha tien chiaotzu bulma chi-chi<br>
- roshi))])<br>
- (insert-last/data! t2 name))<br>
-(define tree-of-mighty-z-warriors (join! t1 t2))<br>
-(tree-items tree-of-mighty-z-warriors)<br>
-]<br>
-<br>
-Note that @racket[t1] and @racket[t2] should share the same<br>
-@racket[tree-metadata-f] and neither tree should be @racket[eq?] to the other.<br>
-Violations of either condition will raise a contract error.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define t1 (new-tree))<br>
-(join! t1 t1)<br>
-]<br>
-}<br>
-<br>
-<br>
-@defproc[(concat! [t1 tree?] [n singleton-node?] [t2 tree?]) tree?]{<br>
-Destructively joins tree @racket[t1], singleton node @racket[n], and tree<br>
-@racket[t2], returning a tree that has the contents of both. Every element in<br>
-@racket[t1] is treated less than @racket[x], and @racket[x] is treated smaller than all<br>
-the elements in @racket[t2].<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define t1 (new-tree))<br>
-(define t2 (new-tree))<br>
-(insert-last/data! t1 "inigo")<br>
-(define x (new-node "vizzini"))<br>
-(insert-last/data! t2 "fezzik")<br>
-(define poor-lost-circus-performers (concat! t1 x t2))<br>
-(tree-items poor-lost-circus-performers)<br>
-]<br>
-<br>
-<br>
-Note that @racket[t1] and @racket[t2] should share the same<br>
-@racket[tree-metadata-f] and neither tree should be @racket[eq?] to the other.<br>
-Violations of either condition will raise a contract error.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define (f1 data left right) 1)<br>
-(define (f2 data left right) 1)<br>
-@code:comment{f1 and f2 are distinct function values: they won't compare the same.}<br>
-(define t1 (new-tree #:metadata-f f1))<br>
-(define t2 (new-tree #:metadata-f f2))<br>
-(define n (new-node "a-node"))<br>
-(concat! t1 n t2)<br>
-]<br>
-}<br>
-<br>
-<br>
-@defproc[(split! [t tree?] [n non-nil-node?]) (values tree? tree?)]{<br>
-Destructively splits tree @racket[t] into two trees, the first containing the<br>
-elements smaller than node @racket[n], and the second containing those larger.<br>
-Afterwards, @racket[n] becomes a singleton node.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define t (new-tree))<br>
-(for ([name '(melchior caspar bob balthazar)])<br>
- (insert-last/data! t name))<br>
-(define bob-node (predecessor (tree-last t)))<br>
-(singleton-node? bob-node)<br>
-(define-values (l r) (split! t bob-node))<br>
-@code:comment{We tree kings of orient are:}<br>
-(append (tree-items l) (tree-items r))<br>
-(singleton-node? bob-node)<br>
-]<br>
-<br>
-Note that @racket[n] must be attached to tree @racket[t] or else raise<br>
-a contract error.<br>
-@interaction[#:eval my-eval<br>
-(define t (new-tree))<br>
-(for ([name '(melchior caspar bob balthazar)])<br>
- (insert-last/data! t name))<br>
-@code:comment{This should raise an error:}<br>
-(define t2 (new-tree))<br>
-(insert-last! t2 (new-node "bob"))<br>
-(split! t (tree-root t2))<br>
-]}<br>
-<br>
-<br>
-@defproc[(reset! [t tree?]) void?]{<br>
-Resets the contents of the tree to the empty state.<br>
-@interaction[#:eval my-eval<br>
-(define t (new-tree))<br>
-(insert-last/data! t "house")<br>
-(insert-last/data! t "cleaning")<br>
-(tree-items t)<br>
-(reset! t)<br>
-(tree-items t)]<br>
-}<br>
-<br>
-<br>
-<br>
-@defproc[(minimum [n node?]) node?]{<br>
-Given a node @racket[n], returns the minimum element of the subtree rooted at<br>
-@racket[n].<br>
-@interaction[#:eval my-eval<br>
-(define t (new-tree))<br>
-(for ([x (in-list '("ftl" "xcom" "civ"))])<br>
- (insert-first/data! t x))<br>
-(node-data (minimum (tree-root t)))<br>
-]<br>
-Note: to get the minimum of a whole tree, it's faster to use<br>
-@racket[tree-first].<br>
-}<br>
-<br>
-<br>
-@defproc[(maximum [n node?]) node?]{<br>
-Given a node @racket[n], returns the maximum element of the subtree rooted at<br>
-@racket[n].<br>
-@interaction[#:eval my-eval<br>
-(define t (new-tree))<br>
-(for ([x (in-list '("ftl" "xcom" "civ"))])<br>
- (insert-first/data! t x))<br>
-(node-data (maximum (tree-root t)))<br>
-]<br>
-Note: to get the maximum of a whole tree, it's faster to use<br>
-@racket[tree-last].<br>
-}<br>
-<br>
-<br>
-@defproc[(successor [n node?]) node?]{<br>
-Given a node @racket[n] contained in some tree, returns the immediate<br>
-successor of @racket[n] in an inorder traversal of that tree.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define partial-alien-tree (new-tree))<br>
-(for ([name '("sectoid" "floater" "thin man" "chryssalid"<br>
- "muton" "cyberdisk")])<br>
- (insert-last/data! partial-alien-tree name))<br>
-(define first-alien (tree-first partial-alien-tree))<br>
-(node-data (successor first-alien))<br>
-(node-data (successor (successor first-alien)))<br>
-]<br>
-}<br>
-<br>
-<br>
-<br>
-@defproc[(predecessor [n node?]) node?]{<br>
-Given a node @racket[n] contained in some tree, returns the immediate<br>
-predecessor of @racket[n] in an inorder traversal of that tree.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define partial-alien-tree (new-tree))<br>
-(for ([name '("sectoid" "floater" "thin man" "chryssalid"<br>
- "muton" "cyberdisk")])<br>
- (insert-last/data! partial-alien-tree name))<br>
-(define last-alien (tree-last partial-alien-tree))<br>
-(node-data (predecessor last-alien))<br>
-(node-data (predecessor (predecessor last-alien)))<br>
-]<br>
-}<br>
-<br>
-<br>
-<br>
-@defproc[(tree-items [t tree?]) (listof/c (list/c any/c natural-number/c))]{<br>
-Given a tree, returns a list of its data and width pairs.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define t (new-tree))<br>
-(insert-last/data! t "rock")<br>
-(insert-last/data! t "paper")<br>
-(insert-last/data! t "scissors")<br>
-(tree-items t)<br>
-]<br>
-}<br>
-<br>
-<br>
-@deftogether[<br>
-(@defproc[(tree-fold-inorder [t tree?] [f (node? any/c . -> . any)] [acc any/c]) any]{}<br>
- @defproc[(tree-fold-preorder [t tree?] [f (node? any/c . -> . any)] [acc any/c]) any]{}<br>
- @defproc[(tree-fold-postorder [t tree?] [f (node? any/c . -> . any)] [acc any/c]) any]{})]{<br>
-<br>
-Iterates a function @racket[f] across the nodes of the tree, in inorder, preorder,<br>
-and postorder respectively.<br>
-<br>
-@interaction[#:eval my-eval<br>
-(define t (new-tree))<br>
-(insert-last/data! t "three")<br>
-(insert-last/data! t "blind")<br>
-(insert-last/data! t "mice")<br>
-@code:comment{"blind" should be the root, with}<br>
-@code:comment{"three" and "mice" as left and right.}<br>
-(define (f n acc) (cons (node-data n) acc))<br>
-(reverse (tree-fold-inorder t f '()))<br>
-(reverse (tree-fold-preorder t f '()))<br>
-(reverse (tree-fold-postorder t f '()))<br>
-]<br>
-<br>
-}<br>
-<br>
-<br>
-@section{Uncontracted library}<br>
-<br>
-This library uses contracts extensively to prevent the user from messing up;<br>
-however, the contract checking may be prohibitively<br>
-expensive for certain applications.<br>
-<br>
-The uncontracted bindings of this library can be accessed through:<br>
-<br>
-@racketblock[(require (submod syntax-color/private/red-black uncontracted))]<br>
-<br>
-This provides the same bindings as the regular API, but with no contract<br>
-checks. Use this with extreme care: Improper use of the uncontracted form of<br>
-this library may lead to breaking the red-black invariants, or (even worse)<br>
-introducing cycles in the structure. If you don't know whether you should be<br>
-using the uncontracted forms or not, you probably should not.<br>
-<br>
-<br>
-@section{Bibliography}<br>
-<br>
-@bibliography[<br>
-@bib-entry[#:key "clrs2009"<br>
- #:title "Introduction to Algorithms, Third Edition"<br>
- #:is-book? #t<br>
- #:author "Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford Stein"<br>
- #:date "2009"<br>
- #:url "<a href="http://mitpress.mit.edu/books/introduction-algorithms" target="_blank">http://mitpress.mit.edu/books/introduction-algorithms</a>"]<br>
-<br>
-@bib-entry[#:key "wein2005"<br>
- #:title "Efficient implementation of red-black trees with split and catenate operations"<br>
- #:author "Ron Wein"<br>
- #:date "2005"<br>
- #:url "<a href="http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.109.4875" target="_blank">http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.109.4875</a>"]<br>
-]<br>
-<br>
-<br>
-<br>
-<br>
-@close-eval[my-eval]<br>
\ No newline at end of file<br>
<br>
</blockquote></div><br></div>