cl-scopes/csys/space.lisp

38 lines
979 B
Common Lisp

;;;; cl-scopes/csys/space
;;;; definitions for (spatial) registering and retrieving objects by location
(defpackage :scopes/csys/space
(:use :common-lisp)
(:local-nicknames (:alx :alexandria)
(:util :scopes/util))
(:export #:create #:put #:del #:fetch #:query
#:neighbors #:free-loc-at #:distance-sq))
(in-package :scopes/csys/space)
(defun create ()
(make-hash-table :test #'equalp))
(defun put (spc loc obj)
(let ((current (gethash loc spc)))
(if current
;(util:lgw "location already occupied" spc loc current obj)
(error "location already occupied! space: ~s, loc: ~s, current: ~s, new: ~s"
spc loc current obj)
(setf (gethash loc spc) obj))))
(defun del (spc loc)
(remhash loc spc))
(defun fetch (spc loc)
(gethash loc spc))
(defun query (spc pattern)
nil)
(defun neighbors (spc loc &key (dist 2)))
(defun free-loc-at (spc loc &key (dist 2)))
(defun distance-sq (spc loc1 loc2))