[Groonga-commit] groonga/grnxx at ea907b3 [master] Update Sorter to support NaN.

Back to archive index

susumu.yata null+****@clear*****
Thu Jul 31 03:28:17 JST 2014


susumu.yata	2014-07-31 03:28:17 +0900 (Thu, 31 Jul 2014)

  New Revision: ea907b35cf0d655fb37622010e7dfac4b6a1c782
  https://github.com/groonga/grnxx/commit/ea907b35cf0d655fb37622010e7dfac4b6a1c782

  Message:
    Update Sorter to support NaN.
    
    Numbers are prior to NaN (Not-a-Number).

  Modified files:
    lib/grnxx/sorter.cpp

  Modified: lib/grnxx/sorter.cpp (+16 -0)
===================================================================
--- lib/grnxx/sorter.cpp    2014-07-30 19:49:40 +0900 (cda61a3)
+++ lib/grnxx/sorter.cpp    2014-07-31 03:28:17 +0900 (5da7812)
@@ -1,5 +1,7 @@
 #include "grnxx/sorter.hpp"
 
+#include <cmath>
+
 #include "grnxx/error.hpp"
 #include "grnxx/expression.hpp"
 #include "grnxx/order.hpp"
@@ -49,6 +51,20 @@ struct RegularComparer {
 };
 
 template <>
+struct RegularComparer<Float> {
+  using Value = Float;
+  bool operator()(Value lhs, Value rhs) const {
+    // Numbers are prior to NaN.
+    if (std::isnan(lhs)) {
+      return false;
+    } else if (std::isnan(rhs)) {
+      return true;
+    }
+    return lhs < rhs;
+  }
+};
+
+template <>
 struct RegularComparer<GeoPoint> {
   using Value = GeoPoint;
   bool operator()(Value lhs, Value rhs) const {
-------------- next part --------------
HTML����������������������������...
Download 



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