Skip to content

Instantly share code, notes, and snippets.

@psilord
Created October 7, 2024 05:21
Show Gist options
  • Save psilord/471835b65eb5a63c39eb1f51333b8781 to your computer and use it in GitHub Desktop.
Save psilord/471835b65eb5a63c39eb1f51333b8781 to your computer and use it in GitHub Desktop.
(defclass bsm-mapid-table ()
((%by-key :reader by-key
:initarg :by-key
:initform nil)
(%by-value :reader by-value
:initarg :by-value
:initform nil)))
(defun bsm-make-bsm-mapid-table (by-key-test by-value-test)
(bsm-mapid-table :by-key (make-hash-table :test by-key-test)
:by-value (make-hash-table :test by-value-test)))
(defun bsm-put-mapid-table (key value mitbl)
(puthash key value (by-key mitbl))
(puthash value value (by-value mitbl)))
(defun bsm-get-mapid-table (thing mitbl)
(let ((item (gethash thing (by-key mitbl))))
(if item
item
(let ((item (gethash thing (by-value mitbl))))
(if item
item
nil)))))
(defun bsm-remhash-mapid-table (thing mitbl)
(remhash thing (by-key mitbl))
(remhash thing (by-value mitbl)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment