This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: home-directory in .kawarc.scm; kawa.init for SLIB; hash tables


"Nic Ferrier" <nferrier@tapsellferrier.co.uk> writes:

> BRL has a Hash interface as I recall...

Yes.  It uses the Java 1.1 Hashtable class for now.  When Kawa depends
on newer classes I may change it.

;
; Generic hash table interface
;

(define (brl-hash)
  (make <java.util.Hashtable>))

(define (brl-hash? obj)
  (instance? obj <java.util.Dictionary>))

(define (brl-hash-size hh :: <java.util.Dictionary>)
  (make <integer> (invoke hh 'size)))

(define (brl-hash-put! hh :: <java.util.Dictionary> key val)
  (invoke hh 'put key val))

(define (brl-hash-get hh :: <java.util.Dictionary> key)
  (let ((result (invoke hh 'get key)))
    (if (eq? #!null result)
	#f				; as assoc does
	result)))

(define (brl-hash-remove! hh :: <java.util.Dictionary> key)
  (invoke hh 'remove key))

(define (brl-hash-keys hh :: <java.util.Dictionary>)
  (letrec ((enum (lambda (ee :: <java.util.Enumeration>)
		   (if (invoke ee 'hasMoreElements)
		       (let ((nxt (invoke ee 'nextElement)))
			 (cons nxt (enum ee)))
		       '()))))
    (enum (invoke hh 'keys))))

(define (brl-hash-contains-key? hh :: <java.util.Hashtable> key)
  (invoke hh 'containsKey key))


-- 
Bruce R. Lewis				http://brl.sourceforge.net/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]