home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / setf / strhash.el < prev    next >
Encoding:
Text File  |  1992-04-22  |  1.8 KB  |  50 lines

  1. ;;; $Header: /home/user3/miles/src/elisp/RCS/strhash.el,v 1.5 1992/04/16 13:44:21 miles Exp $
  2. ;;; ----------------------------------------------------------------
  3. ;;; strhash.el -- String keyed hash-tables
  4. ;;; Copyright (C) April 1992, Miles Bader <miles@cogsci.ed.ac.uk>
  5. ;;; ----------------------------------------------------------------
  6. ;;; This program is free software; you can redistribute it and/or modify
  7. ;;; it under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 2 of the License, or
  9. ;;; (at your option) any later version.
  10. ;;;
  11. ;;; This program is distributed in the hope that it will be useful,
  12. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with this program; if not, write to the Free Software
  18. ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. ;;; ----------------------------------------------------------------
  20. ;;;
  21. ;;; A set of wrapper macros for intern & intern-soft to implement
  22. ;;; string-keyed hash-tables.
  23. ;;;
  24.  
  25. (provide 'strhash)
  26.  
  27. (require 'backquote)
  28. (require 'setf)
  29.  
  30. (defconst strhash-default-size 91)
  31.  
  32. (defmacro make-strhash-table (&optional size)
  33.   (` (make-vector (, (or size string-hash-default-size)) 0)))
  34.  
  35. (defmacro strhash-get (table string)
  36.   (` (symbol-value (intern-soft (, string) (, table)))))
  37.  
  38. (defmacro strhash-has-entry-p (table string)
  39.   (` (intern-soft (, string) (, table))))
  40.  
  41. (defsetf strhash-get (table string) (val)
  42.   (` (set (intern (, string) (, table)) (, val))))
  43.  
  44. (defmacro strhash-map (fun table) 
  45.   (` (mapatoms (function (lambda (sym)
  46.                (funcall (, fun)
  47.                     (symbol-name sym)
  48.                     (symbol-value sym))))
  49.            (, table))))
  50.