Changeset 27175 in project


Ignore:
Timestamp:
08/03/12 15:52:19 (9 years ago)
Author:
juergen
Message:

removed dependency on records, define-record-type and
define-record-printer used

Location:
release/4/skiplists
Files:
6 edited
3 copied

Legend:

Unmodified
Added
Removed
  • release/4/skiplists/tags/0.7/skiplists.meta

    r25403 r27175  
    44 (category data)
    55 (license "BSD")
    6  (depends contracts records)
     6 (depends contracts)
    77 (doc-from-wiki #t)
    88 (author "Juergen Lorenz")
  • release/4/skiplists/tags/0.7/skiplists.scm

    r27161 r27175  
    7474;below n.
    7575;
    76 (require-library records contracts)
     76(require-library contracts)
    7777
    7878(module %skiplists
     
    8484   skip-filter)
    8585
    86 (import scheme records
     86(import scheme
    8787  (only chicken
    88     assert when unless keyword? optional
    89     getter-with-setter print); get-output-string open-output-string)
    90   (only data-structures list-of?)
     88        define-record-type define-record-printer
     89        assert when unless keyword? optional
     90        getter-with-setter); get-output-string open-output-string)
    9191  (only extras random))
    9292
    9393;;;; skipnode ADT (hidden)
    9494
    95 (define skipnode-type (make-record-type 'skipnode '(item next)))
    96 
    97 (define make-skipnode
    98   (record-constructor skipnode-type))
    99 
    100 (define skipnode? (record-predicate skipnode-type))
    101 
    102 (define skipnode-item
    103   (record-accessor skipnode-type 'item))
    104 
    105 (define skip-next
    106   (record-accessor skipnode-type 'next))
     95(define skipnode-type
     96  (define-record-type skipnode
     97    (make-skipnode item next)
     98    skipnode?
     99    (item skipnode-item)
     100    (next skip-next)))
     101
     102(define-record-printer (skipnode node out)
     103  (display "#<item " out)
     104  (display (skipnode-item node) out)
     105  ;(display ") (next " out)
     106  ;(display (skipnode-next node (vector-length (skip-next node))) out)
     107  (display ">" out))
    107108
    108109(define (skipnode-links node)
     
    142143
    143144(define skip-type
    144   (make-record-type 'skiplist
    145     '(orders gap links count cursor start)))
    146 
    147 (define skiplist?  (record-predicate skip-type))
    148 
    149 (define skip-maker
    150   (record-constructor skip-type))
    151 
    152 (define skip-orders (record-accessor skip-type 'orders))
    153 
    154 (define skip-gap (record-accessor skip-type 'gap))
     145  (define-record-type skiplist
     146    (skip-maker orders gap links count cursor start)
     147    skiplist?
     148    (orders skip-orders)
     149    (gap skip-gap)
     150    (links skip-type-links skip-type-links-set!)
     151    (count skip-type-count skip-type-count-set!)
     152    (cursor skip-type-cursor)
     153    (start skip-type-start)))
    155154
    156155(define skip-count
    157   (getter-with-setter (record-accessor skip-type 'count)
    158                       (record-modifier skip-type 'count)))
     156  (getter-with-setter skip-type-count
     157                      skip-type-count-set!))
    159158
    160159(define skip-links
    161   (getter-with-setter (record-accessor skip-type 'links)
    162                       (record-modifier skip-type 'links)))
     160  (getter-with-setter skip-type-links
     161                      skip-type-links-set!))
    163162
    164163(define (skip-cursor skp)
    165   (make-skipnode cursor: ((record-accessor skip-type 'cursor) skp)))
     164  (make-skipnode start: (skip-type-cursor skp)))
    166165
    167166(define (skip-start skp)
    168   (make-skipnode start: ((record-accessor skip-type 'start) skp)))
     167  (make-skipnode start: (skip-type-start skp)))
     168
     169(define-record-printer (skiplist skp out)
     170  (display "#<skiplist (orders " out)
     171  (display (skip-orders skp) out)
     172  (display ") (gap " out)
     173  (display (skip-gap skp) out)
     174  (display ") (links " out)
     175  (display (skip-type-links skp) out)
     176  (display ") (count " out)
     177  (display (skip-type-count skp) out)
     178  (display ") (dups? " out)
     179  (display (skip-dups? skp) out)
     180  (display ")\n(cursor " out)
     181  (display (skip-type-cursor skp) out)
     182  (display ")\n(start " out)
     183  (display (skip-type-start skp) out)
     184  (display ")>\n" out))
    169185
    170186(define (make-skiplist max-links . orders)
     
    346362(import scheme
    347363  (prefix %skiplists %)
    348   (only contracts doclist doclist->dispatcher contract define-with-contract)
     364  (only contracts doclist doclist->dispatcher define-with-contract)
    349365  (only chicken unless get-output-string open-output-string)
    350366  (only data-structures list-of?))
  • release/4/skiplists/tags/0.7/skiplists.setup

    r27161 r27175  
    88 'skiplists
    99 '("skiplists.so" "%skiplists.import.so" "skiplists.import.so")
    10  '((version "0.6")))
     10 '((version "0.7")))
    1111
    1212
  • release/4/skiplists/tags/0.7/tests/run.scm

    r25462 r27175  
    11;;; skiplists/run.scm
    22
    3 (require 'skiplists)
     3(require-library skiplists)
    44(import skiplists)
    55
  • release/4/skiplists/trunk/skiplists.meta

    r25403 r27175  
    44 (category data)
    55 (license "BSD")
    6  (depends contracts records)
     6 (depends contracts)
    77 (doc-from-wiki #t)
    88 (author "Juergen Lorenz")
  • release/4/skiplists/trunk/skiplists.scm

    r27161 r27175  
    7474;below n.
    7575;
    76 (require-library records contracts)
     76(require-library contracts)
    7777
    7878(module %skiplists
     
    8484   skip-filter)
    8585
    86 (import scheme records
     86(import scheme
    8787  (only chicken
    88     assert when unless keyword? optional
    89     getter-with-setter print); get-output-string open-output-string)
    90   (only data-structures list-of?)
     88        define-record-type define-record-printer
     89        assert when unless keyword? optional
     90        getter-with-setter); get-output-string open-output-string)
    9191  (only extras random))
    9292
    9393;;;; skipnode ADT (hidden)
    9494
    95 (define skipnode-type (make-record-type 'skipnode '(item next)))
    96 
    97 (define make-skipnode
    98   (record-constructor skipnode-type))
    99 
    100 (define skipnode? (record-predicate skipnode-type))
    101 
    102 (define skipnode-item
    103   (record-accessor skipnode-type 'item))
    104 
    105 (define skip-next
    106   (record-accessor skipnode-type 'next))
     95(define skipnode-type
     96  (define-record-type skipnode
     97    (make-skipnode item next)
     98    skipnode?
     99    (item skipnode-item)
     100    (next skip-next)))
     101
     102(define-record-printer (skipnode node out)
     103  (display "#<item " out)
     104  (display (skipnode-item node) out)
     105  ;(display ") (next " out)
     106  ;(display (skipnode-next node (vector-length (skip-next node))) out)
     107  (display ">" out))
    107108
    108109(define (skipnode-links node)
     
    142143
    143144(define skip-type
    144   (make-record-type 'skiplist
    145     '(orders gap links count cursor start)))
    146 
    147 (define skiplist?  (record-predicate skip-type))
    148 
    149 (define skip-maker
    150   (record-constructor skip-type))
    151 
    152 (define skip-orders (record-accessor skip-type 'orders))
    153 
    154 (define skip-gap (record-accessor skip-type 'gap))
     145  (define-record-type skiplist
     146    (skip-maker orders gap links count cursor start)
     147    skiplist?
     148    (orders skip-orders)
     149    (gap skip-gap)
     150    (links skip-type-links skip-type-links-set!)
     151    (count skip-type-count skip-type-count-set!)
     152    (cursor skip-type-cursor)
     153    (start skip-type-start)))
    155154
    156155(define skip-count
    157   (getter-with-setter (record-accessor skip-type 'count)
    158                       (record-modifier skip-type 'count)))
     156  (getter-with-setter skip-type-count
     157                      skip-type-count-set!))
    159158
    160159(define skip-links
    161   (getter-with-setter (record-accessor skip-type 'links)
    162                       (record-modifier skip-type 'links)))
     160  (getter-with-setter skip-type-links
     161                      skip-type-links-set!))
    163162
    164163(define (skip-cursor skp)
    165   (make-skipnode cursor: ((record-accessor skip-type 'cursor) skp)))
     164  (make-skipnode start: (skip-type-cursor skp)))
    166165
    167166(define (skip-start skp)
    168   (make-skipnode start: ((record-accessor skip-type 'start) skp)))
     167  (make-skipnode start: (skip-type-start skp)))
     168
     169(define-record-printer (skiplist skp out)
     170  (display "#<skiplist (orders " out)
     171  (display (skip-orders skp) out)
     172  (display ") (gap " out)
     173  (display (skip-gap skp) out)
     174  (display ") (links " out)
     175  (display (skip-type-links skp) out)
     176  (display ") (count " out)
     177  (display (skip-type-count skp) out)
     178  (display ") (dups? " out)
     179  (display (skip-dups? skp) out)
     180  (display ")\n(cursor " out)
     181  (display (skip-type-cursor skp) out)
     182  (display ")\n(start " out)
     183  (display (skip-type-start skp) out)
     184  (display ")>\n" out))
    169185
    170186(define (make-skiplist max-links . orders)
     
    346362(import scheme
    347363  (prefix %skiplists %)
    348   (only contracts doclist doclist->dispatcher contract define-with-contract)
     364  (only contracts doclist doclist->dispatcher define-with-contract)
    349365  (only chicken unless get-output-string open-output-string)
    350366  (only data-structures list-of?))
  • release/4/skiplists/trunk/skiplists.setup

    r27161 r27175  
    88 'skiplists
    99 '("skiplists.so" "%skiplists.import.so" "skiplists.import.so")
    10  '((version "0.6")))
     10 '((version "0.7")))
    1111
    1212
  • release/4/skiplists/trunk/tests/run.scm

    r25462 r27175  
    11;;; skiplists/run.scm
    22
    3 (require 'skiplists)
     3(require-library skiplists)
    44(import skiplists)
    55
Note: See TracChangeset for help on using the changeset viewer.