From: rkk on
I have an application where I create and store triangles, a triangle
being a set of 3 points,
(p0 p1 p2). The triangles are created and stored using something along
the lines of

(defun make-triangle (p0 p1 p2)
(setf (get-hash (get-next-id) *TRIANGLES*) (list p0 p1 p2)))

where (get-next-id) returns a unique id. *TRIANGLES* is defined as

(defvar *TRIANGLES* (make-hash-table))

Two triangles are "equal" if they have the same points. The order of
the points is not important,
and hence I defined the following:

(defun set-equal? (set1 set2)
(and (eql (set-difference set1 set2) nil) (eql (set-difference set2
set1) nil)))

Two triangles share an edge / are said to be connected if (= 2 (length
(intersection tr1 tr2))) etc.

In my application, I cannot have duplicate triangles, so right now,
before I call make-triangle, I check
if *TRIANGLES* already has an existing triangle with the same points
by walking through the hashtable.

Currently my (key,value) corresponds to (id, (p0,p1,p2)). My question
is can I invert this and instead have
(key,value) correspond to ((p0,p1,p2), id). To do this, I would need
to have something like

(defvar *TRIANGLES* (make-hash-table :test #'set-equal?))

I know the standard does not allow this, but has anyone implemented
custom hash tables where this can be done?

Thanks in advance
rkk