[Groonga-commit] groonga/grnxx at 09aae42 [master] Add equality test operators for Vector<Int/Float>.

Back to archive index

susumu.yata null+****@clear*****
Thu Aug 28 13:49:21 JST 2014


susumu.yata	2014-08-28 13:49:21 +0900 (Thu, 28 Aug 2014)

  New Revision: 09aae421d02f5ba0a4d027f8fb1ef35d9dbaeb29
  https://github.com/groonga/grnxx/commit/09aae421d02f5ba0a4d027f8fb1ef35d9dbaeb29

  Message:
    Add equality test operators for Vector<Int/Float>.

  Modified files:
    include/grnxx/types.hpp

  Modified: include/grnxx/types.hpp (+46 -0)
===================================================================
--- include/grnxx/types.hpp    2014-08-28 13:43:11 +0900 (88a6760)
+++ include/grnxx/types.hpp    2014-08-28 13:49:21 +0900 (a014394)
@@ -321,6 +321,29 @@ class Vector<Int> {
   Int size_;
 };
 
+inline Bool operator==(Vector<Int> lhs, Vector<Int> rhs) {
+  if (lhs.size() != rhs.size()) {
+    return false;
+  }
+  for (Int i = 0; i < lhs.size(); ++i) {
+    if (lhs[i] != rhs[i]) {
+      return false;
+    }
+  }
+  return true;
+}
+inline Bool operator!=(Vector<Int> lhs, Vector<Int> rhs) {
+  if (lhs.size() != rhs.size()) {
+    return true;
+  }
+  for (Int i = 0; i < lhs.size(); ++i) {
+    if (lhs[i] != rhs[i]) {
+      return true;
+    }
+  }
+  return false;
+}
+
 template <>
 class Vector<Float> {
  public:
@@ -353,6 +376,29 @@ class Vector<Float> {
   Int size_;
 };
 
+inline Bool operator==(Vector<Float> lhs, Vector<Float> rhs) {
+  if (lhs.size() != rhs.size()) {
+    return false;
+  }
+  for (Int i = 0; i < lhs.size(); ++i) {
+    if (lhs[i] != rhs[i]) {
+      return false;
+    }
+  }
+  return true;
+}
+inline Bool operator!=(Vector<Float> lhs, Vector<Float> rhs) {
+  if (lhs.size() != rhs.size()) {
+    return true;
+  }
+  for (Int i = 0; i < lhs.size(); ++i) {
+    if (lhs[i] != rhs[i]) {
+      return true;
+    }
+  }
+  return false;
+}
+
 using BoolVector  = Vector<Bool>;
 using IntVector   = Vector<Int>;
 using FloatVector = Vector<Float>;
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index