Changeset 30139 in project


Ignore:
Timestamp:
11/27/13 16:09:38 (6 years ago)
Author:
juergen
Message:

treaps 0.1.2

Location:
release/4/treaps
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • release/4/treaps/tags/0.1.2/tests/run.scm

    r30115 r30139  
    55(compound-test (treaps)
    66  (define-test (treap)
    7     "MAKE A NEW EMPTY TREAP ..."
    8     (define trp (make-treap - string?))
    9     (treap? trp)
    10     (treap-empty? trp)
    11     ((treap-key? trp) 1)
    12     (eq? (treap-compare trp) -)
    13     (eq? (treap-value? trp) string?)
    14     "... AND POPULATE IT"
    15     (do ((n 0 (+ n 1)))
    16       ((= n 1000) trp)
    17       (let ((key (random 10000)))
    18         (treap-put! trp key (->string key))))
    19     (positive? (treap-size trp))
    20     (not (treap-empty? trp))
    21     "CHECK MIN AND MAX"
    22     (if (not (treap-get trp 0 #f))
    23       (not (treap-put! trp 0 "0"))
    24       (treap-put! trp 0 "0"))
    25     (equal? (treap-get-min trp) (cons 0 "0"))
    26     (not (treap-put! trp 10000 "10000"))
    27     (equal? (treap-get-max trp) (cons 10000 "10000"))
    28     (not (treap-get trp -5 #f))
    29     (if (not (treap-get trp 10 #f))
    30       (not (treap-put! trp 10 "10"))
    31       (treap-put! trp 10 "10"))
    32     (equal? (treap-get trp 10 #f) (cons 10 "10"))
    33     (treap-delete-min! trp)
    34     (not (treap-get trp 0 #f))
    35     (treap-delete! trp (car (treap-get-min trp)) #f)
    36     (treap-delete-max! trp)
    37     (not (treap-get trp 10000 #f))
    38     "INSERT AND DELETE A PAIR"
    39     (if (not (treap-get trp 10 #f))
    40       (not (treap-put! trp 10 "10"))
    41       (treap-put! trp 10 "10"))
    42     (equal? (treap-delete! trp 10 "not found") (cons 10 "10"))
    43     "TRY TO DELETE A NONEXISTING PAIR"
    44     (not (treap-delete! trp -10 #f))
    45     "CLEAR THE TREAP"
    46     (treap-clear! trp)
    47     (treap-empty? trp)
    48     (= (treap-size trp) 0)
    49     "POPULATE IT AGAIN WITH LESS PAIRS"
    50     (let loop ((n 100))
    51       (unless (fx= n 0)
    52         (let ((k (random 10000)))
    53           (treap-put! trp k (->string k)))
    54         (loop (fx- n 1))))
    55     (<= 0 (treap-size trp) 100)
    56     (not (treap-empty? trp))
    57     "CHECK THE TWO FOR-EACH ROUTINES"
    58     (define keys '())
    59     (treap-for-each-ascending trp
    60                               (lambda (pair)
    61                                 (set! keys
    62                                   (cons (car pair) keys))))
    63     (apply > keys)
    64     (set! keys '())
    65     (treap-for-each-descending trp
    66                               (lambda (pair)
    67                                 (set! keys
    68                                   (cons (car pair) keys))))
    69     (apply < keys)
    70     "IS DEPTH WORKING?"
    71     (positive? (treap-depth trp)))
     7    (check
     8      "MAKE A NEW EMPTY TREAP ..."
     9      (define trp (make-treap - string?))
     10      (treap? trp)
     11      (treap-empty? trp)
     12      ((treap-key? trp) 1)
     13      (eq? (treap-compare trp) -)
     14      (eq? (treap-value? trp) string?)
     15      "... AND POPULATE IT"
     16      (do ((n 0 (+ n 1)))
     17        ((= n 1000) trp)
     18        (let ((key (random 10000)))
     19          (treap-put! trp key (->string key))))
     20      (positive? (treap-size trp))
     21      (not (treap-empty? trp))
     22      "CHECK MIN AND MAX"
     23      (if (not (treap-get trp 0 #f))
     24        (not (treap-put! trp 0 "0"))
     25        (treap-put! trp 0 "0"))
     26      (equal? (treap-get-min trp) (cons 0 "0"))
     27      (not (treap-put! trp 10000 "10000"))
     28      (equal? (treap-get-max trp) (cons 10000 "10000"))
     29      (not (treap-get trp -5 #f))
     30      (if (not (treap-get trp 10 #f))
     31        (not (treap-put! trp 10 "10"))
     32        (treap-put! trp 10 "10"))
     33      (equal? (treap-get trp 10 #f) (cons 10 "10"))
     34      (treap-delete-min! trp)
     35      (not (treap-get trp 0 #f))
     36      (treap-delete! trp (car (treap-get-min trp)) #f)
     37      (treap-delete-max! trp)
     38      (not (treap-get trp 10000 #f))
     39      "INSERT AND DELETE A PAIR"
     40      (if (not (treap-get trp 10 #f))
     41        (not (treap-put! trp 10 "10"))
     42        (treap-put! trp 10 "10"))
     43      (equal? (treap-delete! trp 10 "not found") (cons 10 "10"))
     44      "TRY TO DELETE A NONEXISTING PAIR"
     45      (not (treap-delete! trp -10 #f))
     46      "CLEAR THE TREAP"
     47      (treap-clear! trp)
     48      (treap-empty? trp)
     49      (= (treap-size trp) 0)
     50      "POPULATE IT AGAIN WITH LESS PAIRS"
     51      (let loop ((n 100))
     52        (unless (fx= n 0)
     53          (let ((k (random 10000)))
     54            (treap-put! trp k (->string k)))
     55          (loop (fx- n 1))))
     56      (<= 0 (treap-size trp) 100)
     57      (not (treap-empty? trp))
     58      "CHECK THE TWO FOR-EACH ROUTINES"
     59      (define keys '())
     60      (treap-for-each-ascending trp
     61                                (lambda (pair)
     62                                  (set! keys
     63                                    (cons (car pair) keys))))
     64      (apply > keys)
     65      (set! keys '())
     66      (treap-for-each-descending trp
     67                                (lambda (pair)
     68                                  (set! keys
     69                                    (cons (car pair) keys))))
     70      (apply < keys)
     71      "IS DEPTH WORKING?"
     72      (positive? (treap-depth trp))
     73  ))
    7274  (treap)
    7375  )
  • release/4/treaps/tags/0.1.2/treaps.setup

    r30115 r30139  
    77 'treaps
    88 '("treaps.so" "treaps.import.so")
    9  '((version "0.1.1")))
     9 '((version "0.1.2")))
  • release/4/treaps/trunk/tests/run.scm

    r30115 r30139  
    55(compound-test (treaps)
    66  (define-test (treap)
    7     "MAKE A NEW EMPTY TREAP ..."
    8     (define trp (make-treap - string?))
    9     (treap? trp)
    10     (treap-empty? trp)
    11     ((treap-key? trp) 1)
    12     (eq? (treap-compare trp) -)
    13     (eq? (treap-value? trp) string?)
    14     "... AND POPULATE IT"
    15     (do ((n 0 (+ n 1)))
    16       ((= n 1000) trp)
    17       (let ((key (random 10000)))
    18         (treap-put! trp key (->string key))))
    19     (positive? (treap-size trp))
    20     (not (treap-empty? trp))
    21     "CHECK MIN AND MAX"
    22     (if (not (treap-get trp 0 #f))
    23       (not (treap-put! trp 0 "0"))
    24       (treap-put! trp 0 "0"))
    25     (equal? (treap-get-min trp) (cons 0 "0"))
    26     (not (treap-put! trp 10000 "10000"))
    27     (equal? (treap-get-max trp) (cons 10000 "10000"))
    28     (not (treap-get trp -5 #f))
    29     (if (not (treap-get trp 10 #f))
    30       (not (treap-put! trp 10 "10"))
    31       (treap-put! trp 10 "10"))
    32     (equal? (treap-get trp 10 #f) (cons 10 "10"))
    33     (treap-delete-min! trp)
    34     (not (treap-get trp 0 #f))
    35     (treap-delete! trp (car (treap-get-min trp)) #f)
    36     (treap-delete-max! trp)
    37     (not (treap-get trp 10000 #f))
    38     "INSERT AND DELETE A PAIR"
    39     (if (not (treap-get trp 10 #f))
    40       (not (treap-put! trp 10 "10"))
    41       (treap-put! trp 10 "10"))
    42     (equal? (treap-delete! trp 10 "not found") (cons 10 "10"))
    43     "TRY TO DELETE A NONEXISTING PAIR"
    44     (not (treap-delete! trp -10 #f))
    45     "CLEAR THE TREAP"
    46     (treap-clear! trp)
    47     (treap-empty? trp)
    48     (= (treap-size trp) 0)
    49     "POPULATE IT AGAIN WITH LESS PAIRS"
    50     (let loop ((n 100))
    51       (unless (fx= n 0)
    52         (let ((k (random 10000)))
    53           (treap-put! trp k (->string k)))
    54         (loop (fx- n 1))))
    55     (<= 0 (treap-size trp) 100)
    56     (not (treap-empty? trp))
    57     "CHECK THE TWO FOR-EACH ROUTINES"
    58     (define keys '())
    59     (treap-for-each-ascending trp
    60                               (lambda (pair)
    61                                 (set! keys
    62                                   (cons (car pair) keys))))
    63     (apply > keys)
    64     (set! keys '())
    65     (treap-for-each-descending trp
    66                               (lambda (pair)
    67                                 (set! keys
    68                                   (cons (car pair) keys))))
    69     (apply < keys)
    70     "IS DEPTH WORKING?"
    71     (positive? (treap-depth trp)))
     7    (check
     8      "MAKE A NEW EMPTY TREAP ..."
     9      (define trp (make-treap - string?))
     10      (treap? trp)
     11      (treap-empty? trp)
     12      ((treap-key? trp) 1)
     13      (eq? (treap-compare trp) -)
     14      (eq? (treap-value? trp) string?)
     15      "... AND POPULATE IT"
     16      (do ((n 0 (+ n 1)))
     17        ((= n 1000) trp)
     18        (let ((key (random 10000)))
     19          (treap-put! trp key (->string key))))
     20      (positive? (treap-size trp))
     21      (not (treap-empty? trp))
     22      "CHECK MIN AND MAX"
     23      (if (not (treap-get trp 0 #f))
     24        (not (treap-put! trp 0 "0"))
     25        (treap-put! trp 0 "0"))
     26      (equal? (treap-get-min trp) (cons 0 "0"))
     27      (not (treap-put! trp 10000 "10000"))
     28      (equal? (treap-get-max trp) (cons 10000 "10000"))
     29      (not (treap-get trp -5 #f))
     30      (if (not (treap-get trp 10 #f))
     31        (not (treap-put! trp 10 "10"))
     32        (treap-put! trp 10 "10"))
     33      (equal? (treap-get trp 10 #f) (cons 10 "10"))
     34      (treap-delete-min! trp)
     35      (not (treap-get trp 0 #f))
     36      (treap-delete! trp (car (treap-get-min trp)) #f)
     37      (treap-delete-max! trp)
     38      (not (treap-get trp 10000 #f))
     39      "INSERT AND DELETE A PAIR"
     40      (if (not (treap-get trp 10 #f))
     41        (not (treap-put! trp 10 "10"))
     42        (treap-put! trp 10 "10"))
     43      (equal? (treap-delete! trp 10 "not found") (cons 10 "10"))
     44      "TRY TO DELETE A NONEXISTING PAIR"
     45      (not (treap-delete! trp -10 #f))
     46      "CLEAR THE TREAP"
     47      (treap-clear! trp)
     48      (treap-empty? trp)
     49      (= (treap-size trp) 0)
     50      "POPULATE IT AGAIN WITH LESS PAIRS"
     51      (let loop ((n 100))
     52        (unless (fx= n 0)
     53          (let ((k (random 10000)))
     54            (treap-put! trp k (->string k)))
     55          (loop (fx- n 1))))
     56      (<= 0 (treap-size trp) 100)
     57      (not (treap-empty? trp))
     58      "CHECK THE TWO FOR-EACH ROUTINES"
     59      (define keys '())
     60      (treap-for-each-ascending trp
     61                                (lambda (pair)
     62                                  (set! keys
     63                                    (cons (car pair) keys))))
     64      (apply > keys)
     65      (set! keys '())
     66      (treap-for-each-descending trp
     67                                (lambda (pair)
     68                                  (set! keys
     69                                    (cons (car pair) keys))))
     70      (apply < keys)
     71      "IS DEPTH WORKING?"
     72      (positive? (treap-depth trp))
     73  ))
    7274  (treap)
    7375  )
  • release/4/treaps/trunk/treaps.setup

    r30115 r30139  
    77 'treaps
    88 '("treaps.so" "treaps.import.so")
    9  '((version "0.1.1")))
     9 '((version "0.1.2")))
Note: See TracChangeset for help on using the changeset viewer.