removed unused code from unstable/hash

This commit is contained in:
Ryan Culpepper 2011-04-12 09:30:03 -06:00
parent 033e060bf3
commit c0bd4e8dbc
3 changed files with 0 additions and 105 deletions

View File

@ -4,29 +4,6 @@
(run-tests
(test-suite "hash.ss"
(test-suite "hash-ref/check"
(test-ok (check-equal? (hash-ref/check #hash([1 . one] [2 . two]) 1)
'one))
(test-bad (hash-ref/check #hash([1 . one] [2 . two]) 3)))
(test-suite "hash-ref/identity"
(test-ok (check-equal? (hash-ref/identity #hash([1 . one] [2 . two]) 1)
'one))
(test-ok (check-equal? (hash-ref/identity #hash([1 . one] [2 . two]) 3)
3)))
(test-suite "hash-ref/default"
(test-ok (check-equal? (hash-ref/default #hash([1 . one] [2 . two]) 1 '?)
'one))
(test-ok (check-equal? (hash-ref/default #hash([1 . one] [2 . two]) 3 '?)
'?)))
(test-suite "hash-ref/failure"
(test-ok (define x 7)
(define (f) (set! x (+ x 1)) x)
(check-equal? (hash-ref/failure #hash([1 . one] [2 . two]) 1 f)
'one)
(check-equal? x 7)
(check-equal? (hash-ref/failure #hash([1 . one] [2 . two]) 3 f)
8)
(check-equal? x 8)))
(test-suite "hash-union"
(test-ok (hash-union #hash([1 . one] [2 . two])
#hash([3 . three] [4 . four]))
@ -38,4 +15,3 @@
(check-equal? (hash-copy
#hash([1 . one] [2 . two] [3 . three] [4 . four]))
h)))))

View File

@ -1,20 +1,6 @@
#lang racket/base
(require racket/contract)
;; Eli: See comments for `dict-ref/check' and relatives.
(define (hash-ref/check table key)
(hash-ref table key))
(define (hash-ref/identity table key)
(hash-ref table key (lambda () key)))
(define (hash-ref/default table key default)
(hash-ref table key (lambda () default)))
(define (hash-ref/failure table key failure)
(hash-ref table key (lambda () (failure))))
;; Eli: See comment for `dict-union' and `dict-union!' -- these two do
;; make sense, but if they're in, then generalizing them to dictionaries
;; seems to make little sense. If they are useful, I'd much rather see
@ -51,13 +37,6 @@
v))))
(provide/contract
[hash-ref/identity (-> hash? any/c any/c)]
[hash-ref/default (-> hash? any/c any/c any/c)]
[hash-ref/failure (-> hash? any/c (-> any/c) any/c)]
[hash-ref/check
(->i ([table hash?] [key any/c]) ()
#:pre (table key) (hash-has-key? table key)
[res any/c])]
[hash-union (->* [(and/c hash? immutable?)]
[#:combine
(-> any/c any/c any/c)

View File

@ -9,66 +9,6 @@
This module provides tools for manipulating hash tables.
@section{Hash Table Lookup}
@defproc[(hash-ref/check [h hash?] [k (lambda (k) (hash-has-key? h k))])
any/c]{
Looks up key @scheme[k] in hash table @scheme[h]. Raises a contract error if
@scheme[h] has no entry for @scheme[k]. Equivalent to @scheme[(hash-ref h k)],
except for the specific exception value raised.
@defexamples[
#:eval (eval/require 'unstable/hash)
(hash-ref/check (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 2)
]
}
@defproc[(hash-ref/identity [h hash?] [k any/c]) any/c]{
Looks up key @scheme[k] in hash table @scheme[h]. Returns @scheme[k] if
@scheme[h] has no entry for @scheme[k]. Equivalent to
@scheme[(hash-ref h k (lambda () k))].
@defexamples[
#:eval (eval/require 'unstable/hash)
(hash-ref/identity (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 2)
(hash-ref/identity (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 4)
]
}
@defproc[(hash-ref/default [h hash?] [k any/c] [v any/c]) any/c]{
Looks up key @scheme[k] in hash table @scheme[h]. Returns @scheme[v] if
@scheme[h] has no entry for @scheme[k]. Equivalent to
@scheme[(hash-ref h k (lambda () v))].
@defexamples[
#:eval (eval/require 'unstable/hash)
(hash-ref/default (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 2 'other)
(hash-ref/default (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 4 'other)
]
}
@defproc[(hash-ref/failure [h hash?] [k any/c] [f (-> any/c)]) any/c]{
Looks up key @scheme[k] in hash table @scheme[h]. Returns the result of
applying @scheme[f] (in tail position) if @scheme[h] has no entry for
@scheme[k]. Equivalent to @scheme[(hash-ref h k f)].
@defexamples[
#:eval (eval/require 'unstable/hash)
(hash-ref/failure (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 2 gensym)
(hash-ref/failure (make-immutable-hash '([1 . one] [2 . two] [3 . three])) 4 gensym)
]
}
@section{Hash Table Combinations}
@defproc[(hash-union [h0 (and/c hash? hash-can-functional-set?)]
[h hash?] ...
[#:combine combine