about summary refs log tree commit diff stats
path: root/043space.cc
diff options
context:
space:
mode:
Diffstat (limited to '043space.cc')
-rw-r--r--043space.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/043space.cc b/043space.cc
index 9ca747b7..31a4173d 100644
--- a/043space.cc
+++ b/043space.cc
@@ -285,3 +285,18 @@ bool contains_non_special_name(const recipe_ordinal r) {
   }
   return false;
 }
+
+// reagent comparison -- only between reagents in a single recipe
+bool operator==(const reagent& a, const reagent& b) {
+  if (a.name != b.name) return false;
+  if (property(a, "space") != property(b, "space")) return false;
+  return true;
+}
+
+bool operator<(const reagent& a, const reagent& b) {
+  long long int aspace = 0, bspace = 0;
+  if (has_property(a, "space")) aspace = to_integer(property(a, "space")->value);
+  if (has_property(b, "space")) bspace = to_integer(property(b, "space")->value);
+  if (aspace != bspace) return aspace < bspace;
+  return a.name < b.name;
+}