1c5dff36922b

Remove `hash-sets` package.  Use cl-hamt or something instead
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Thu, 03 Nov 2016 18:26:11 +0000
parents 784e50fe72f6
children 66af3dc24580
branches/tags (none)
files DOCUMENTATION.markdown losh.lisp make-docs.lisp package.lisp

Changes

--- a/DOCUMENTATION.markdown	Thu Nov 03 17:37:41 2016 +0000
+++ b/DOCUMENTATION.markdown	Thu Nov 03 18:26:11 2016 +0000
@@ -450,57 +450,6 @@
 
   
 
-## Package `LOSH.HASH-SETS`
-
-A simple hash set implementation.
-
-### `HASH-SET` (class)
-
-#### Slot `DATA`
-
-* Allocation: `:INSTANCE`
-* Initarg: `:DATA`
-
-### `MAKE-SET` (function)
-
-    (MAKE-SET &KEY (TEST #'EQL) (INITIAL-DATA NIL))
-
-### `SET-ADD` (function)
-
-    (SET-ADD SET VALUE)
-
-### `SET-ADD-ALL` (function)
-
-    (SET-ADD-ALL SET SEQ)
-
-### `SET-CLEAR` (function)
-
-    (SET-CLEAR SET)
-
-### `SET-CONTAINS-P` (function)
-
-    (SET-CONTAINS-P SET VALUE)
-
-### `SET-EMPTY-P` (function)
-
-    (SET-EMPTY-P SET)
-
-### `SET-POP` (function)
-
-    (SET-POP SET)
-
-### `SET-RANDOM` (function)
-
-    (SET-RANDOM SET)
-
-### `SET-REMOVE` (function)
-
-    (SET-REMOVE SET VALUE)
-
-### `SET-REMOVE-ALL` (function)
-
-    (SET-REMOVE-ALL SET SEQ)
-
 ## Package `LOSH.ITERATE`
 
 Custom `iterate` drivers and clauses.
--- a/losh.lisp	Thu Nov 03 17:37:41 2016 +0000
+++ b/losh.lisp	Thu Nov 03 18:26:11 2016 +0000
@@ -1215,68 +1215,6 @@
     (finally (return result))))
 
 
-;;;; Hash Sets
-(defclass hash-set ()
-  ((data :initarg :data)))
-
-
-(defun make-set (&key (test #'eql) (initial-data nil))
-  (let ((set (make-instance 'hash-set
-                            :data (make-hash-table :test test))))
-    (mapcar (curry #'set-add set) initial-data)
-    set))
-
-
-(defun set-contains-p (set value)
-  (nth-value 1 (gethash value (slot-value set 'data))))
-
-(defun set-empty-p (set)
-  (zerop (hash-table-count (slot-value set 'data))))
-
-(defun set-add (set value)
-  (setf (gethash value (slot-value set 'data)) t)
-  value)
-
-(defun set-add-all (set seq)
-  (map nil (curry #'set-add set) seq))
-
-(defun set-remove (set value)
-  (remhash value (slot-value set 'data))
-  value)
-
-(defun set-remove-all (set seq)
-  (map nil (curry #'set-remove set) seq))
-
-(defun set-clear (set)
-  (clrhash (slot-value set 'data))
-  set)
-
-(defun set-random (set)
-  (if (set-empty-p set)
-    (values nil nil)
-    (loop :with data = (slot-value set 'data)
-          :with target = (random (hash-table-count data))
-          :for i :from 0
-          :for k :being :the :hash-keys :of data
-          :when (= i target)
-          :do (return (values k t)))))
-
-(defun set-pop (set)
-  (multiple-value-bind (val found) (set-random set)
-    (if found
-      (progn
-        (set-remove set val)
-        (values val t))
-      (values nil nil))))
-
-
-(defmethod print-object ((set hash-set) stream)
-  (print-unreadable-object (set stream :type t)
-    (format stream "~{~S~^ ~}"
-            (iterate (for (key nil) :in-hashtable (slot-value set 'data))
-                     (collect key)))))
-
-
 ;;;; Debugging & Logging
 (defun pr (&rest args)
   "Print `args` readably, separated by spaces and followed by a newline.
--- a/make-docs.lisp	Thu Nov 03 17:37:41 2016 +0000
+++ b/make-docs.lisp	Thu Nov 03 18:26:11 2016 +0000
@@ -9,7 +9,6 @@
         "LOSH.DISTRIBUTIONS"
         "LOSH.ELDRITCH-HORRORS"
         "LOSH.FUNCTIONS"
-        "LOSH.HASH-SETS"
         "LOSH.ITERATE"
         "LOSH.LICENSING"
         "LOSH.LISTS"
--- a/package.lisp	Thu Nov 03 17:37:41 2016 +0000
+++ b/package.lisp	Thu Nov 03 18:26:11 2016 +0000
@@ -147,21 +147,6 @@
     #:prefix-sums
     #:frequencies))
 
-(defpackage #:losh.hash-sets
-  (:documentation "A simple hash set implementation.")
-  (:export
-    #:hash-set
-    #:make-set
-    #:set-contains-p
-    #:set-empty-p
-    #:set-add
-    #:set-add-all
-    #:set-remove
-    #:set-remove-all
-    #:set-clear
-    #:set-random
-    #:set-pop))
-
 (defpackage #:losh.debugging
   (:documentation "Utilities for figuring out what the hell is going on.")
   (:export
@@ -203,7 +188,6 @@
    #:losh.distributions
    #:losh.eldritch-horrors
    #:losh.functions
-   #:losh.hash-sets
    #:losh.iterate
    #:losh.lists
    #:losh.math