From 760a8cbe400e09f7cdee0b5cddedd4c22d7b56bf Mon Sep 17 00:00:00 2001 From: erana Date: Sat, 21 Jan 2012 22:33:42 +0900 Subject: [PATCH] xanadu - xml-tree --- scsh/xanadu/b-tree.scm | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/scsh/xanadu/b-tree.scm b/scsh/xanadu/b-tree.scm index 69fe8aa..fa9751a 100644 --- a/scsh/xanadu/b-tree.scm +++ b/scsh/xanadu/b-tree.scm @@ -156,6 +156,14 @@ (do ((i 0 (+ i 1))) ((cond ((not side-tree) #f) + ((= i (vector-length side-tree)) + (do ((i 0 (+ i 1))) + ((= i (vector-length side-tree))0) + (let ((side-tree-node (vector-ref i side-tree))) + (cond ((not (not side-tree-node)) + #f) + (else (add-rec str side-tree-node)))));;NOTE add-rec not the other add-rec + ) ((let* ((data (((vector-ref side-tree i) 'get-data))) (left-and-right (vector-median side-tree));;FIXME right also descend (new-node (make-b-tree-node @@ -181,17 +189,12 @@ ((new-node 'set-data!) str) (vector-set! side-tree i new-node) )))) - ;;((= i len) - ;; (display "node not added .") 0) - - (else (display "b-tree add - never reached."))))) - (do ((i 0 (+ i 1))) - ((= i (vector-length side-tree))0) - (let ((side-tree-node (vector-ref i side-tree))) - (cond ((not (not side-tree-node)) - #f) - (else (add-rec str side-tree-node)))));;NOTE add-rec not the other add-rec - ) + ((let ((data (((vector-ref side-tree i) 'get-data)))) + (string=? data str) ;;NOTE duplicates possible + (display "b-tree - node already exists.") + 0)) + (else (display "b-tree - add - never reached."))))) + )