-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.lisp
More file actions
39 lines (27 loc) · 860 Bytes
/
map.lisp
File metadata and controls
39 lines (27 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
(in-package :parenboost)
(defpsmacro make-hash-table ()
`(make *map))
(defpsmacro make-weak-hash-table ()
`(make *weak-map))
(defpsmacro hash-table-p (hash)
`(instanceof ,hash *map))
(defpsmacro sethash (key val hash)
`(chain ,hash (set ,key ,val)))
(defpsmacro gethash (key hash)
`(chain ,hash (get ,key)))
(defpsmacro clrhash (hash)
`(chain ,hash (clear)))
(defpsmacro remhash (key hash)
`(chain ,hash (delete ,key)))
(defpsmacro hashash (key hash)
`(chain ,hash (has ,key)))
(defpsmacro hash-table-keys (hash)
`(chain ,hash (keys)))
(defpsmacro hash-table-values (hash)
`(chain ,hash (values)))
(defpsmacro maphash (fun hash)
(with-ps-gensyms (key val)
`(chain ,hash (for-each (lambda (,val ,key)
(funcall ,fun ,key ,val))))))
(defpsmacro hash-table-count (hash)
`(getprop ,hash 'size))