Shared defgeneric copy, elements.

Pascal J. Bourguignon [2015-11-01 05:31]
Shared defgeneric copy, elements.
Filename
common-lisp/cesarum/graph.lisp
common-lisp/cesarum/set.lisp
diff --git a/common-lisp/cesarum/graph.lisp b/common-lisp/cesarum/graph.lisp
index cef74c4..caa3643 100644
--- a/common-lisp/cesarum/graph.lisp
+++ b/common-lisp/cesarum/graph.lisp
@@ -49,6 +49,8 @@
         "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.SET")
   (:shadowing-import-from "COMMON-LISP"
                           "UNION" "INTERSECTION" "MERGE")
+  (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY"
+                "WHILE")
   (:export "EDGE-CLASS" "EDGES" "NODES" "TO" "FROM" "WEIGHT" "INDEX"
            "ELEMENTS" "PROPERTIES" "IDENT" "SHOW-GRAPH" "FIND-NODES-WITH-PROPERTY"
            "COPY" "WALK-EDGES-FROM-NODE" "WALK-FROM-NODE" "FLOW-DISTANCE-FROM-NODE"
@@ -65,7 +67,7 @@
            "SELECT-ELEMENTS" "MAP-ELEMENTS" "PERFORM-WITH-ELEMENTS" "REMOVE-ELEMENT"
            "ADD-ELEMENTS" "CARDINAL" "SET-CLASS" "DELETE-PROPERTY" "GET-PROPERTY"
            "SET-PROPERTY" "PROPERTY-NAMES" "ELEMENT-CLASS")
-  (:import-from "COM.INFORMATIMAGO.COMMON-LISP.CESARUM.UTILITY" "WHILE")
+
   (:documentation
    "

@@ -215,11 +217,6 @@ DO:     Remove the property named `prop-name' from the property list of
 "))


-(defgeneric cardinal (self)
-  (:documentation   "
-RETURN: The number of elements in this set.
-"))
-

 (defgeneric add-elements (self newelementlist)
   (:documentation   "
@@ -244,13 +241,6 @@ NOTE:   lambda-body must not change this set.
 "))


-(defgeneric map-elements (result-type self lambda-body)
-  (:documentation   "
-RETURN: the list of results returned by lambda-body called with each element.
-NOTE:   lambda-body must not change this set.
-"))
-
-
 (defgeneric select-elements (self select-lambda)
   (:documentation   "
 RETURN: A list of elements for which select-lambda returned true.
@@ -520,8 +510,7 @@ DO:     Remove the property named `prop-name' from the property list of


 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-(defgeneric elements (set)
-  (:documentation "The elements in the set."))
+

 (defclass set-class (element-class)
   ((elements
@@ -696,13 +685,6 @@ RETURN: A string describing this element.
             (description (cdr nodes)))))


-(defgeneric copy (self &key &allow-other-keys)
-  (:documentation "
-RETURN: A COPY of this edge.
-        The COPY has the same  NODES than this edge.
-        Other attributes are normally copied."))
-
-
 (defgeneric nodes (self)
   (:documentation "
 RETURN: A list of NODES.
diff --git a/common-lisp/cesarum/set.lisp b/common-lisp/cesarum/set.lisp
index 2a281a8..d61a05f 100644
--- a/common-lisp/cesarum/set.lisp
+++ b/common-lisp/cesarum/set.lisp
@@ -314,12 +314,12 @@ RETURN:         A new set containing only the elements of SET that
                     set))))


-(defgeneric copy                  (set)
+(defgeneric copy (set &key &allow-other-keys)
   (:documentation "
 RETURN:         A new set of same class as SET, containing the same
                 elements as SET.
 ")
-  (:method (set)
+  (:method (set &key &allow-other-keys)
     (assign (make-instance (class-of set)) set)))

 (defgeneric union                 (result-type set1 set2)
@@ -496,6 +496,9 @@ RETURN: SET.
 ;;; A simple implementation to test the default methods.
 ;;;

+(defgeneric elements (set)
+  (:documentation "The elements in the set."))
+
 (defclass list-set ()
   ((elements :initform '() :initarg :elements :reader elements)))
ViewGit