From 381be7373c821b123577720bc10658016267e873 Mon Sep 17 00:00:00 2001
From: Tobias Leibner <tobias.leibner@googlemail.com>
Date: Mon, 3 Dec 2018 13:00:15 +0100
Subject: [PATCH] [vector_less] add structs to be used as comparision in
 std::map and the like

---
 .gitsuper                     | 36 ++++++++++----------
 dune/xt/common/vector_less.hh | 62 +++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 18 deletions(-)
 create mode 100644 dune/xt/common/vector_less.hh

diff --git a/.gitsuper b/.gitsuper
index 19f31f1ab..3e1dea71b 100644
--- a/.gitsuper
+++ b/.gitsuper
@@ -1,7 +1,7 @@
 [supermodule]
-remote = git@github.com:dune-community/dune-xt-super.git
+remote = https://github.com/dune-community/dune-xt-super.git
 status = 1a3bcab04b011a5d6e44f9983cae6ff89fa695e8 bin (heads/master)
-	 5147d438044a772a07fd89ff142d861cfc82212e config.opts (heads/master-13-g5147d43)
+	 5147d438044a772a07fd89ff142d861cfc82212e config.opts (5147d43)
 	 8f2c5aba441417bf2c42f22272f538c68a89cc4a dune-alugrid (remotes/origin/releases/2.5)
 	 707acf201d5a754c80f87cc4d71aa36bf29a6e3f dune-common (v2.5.1-9-g707acf20)
 	 e6350271b8d014adab51467a35b6ad8ef48212a0 dune-geometry (v2.5.1-6-ge635027)
@@ -11,14 +11,14 @@ status = 1a3bcab04b011a5d6e44f9983cae6ff89fa695e8 bin (heads/master)
 	 0d757d65e5d57134a7ecf304e35d063f4ccc7116 dune-localfunctions (v2.5.1rc1)
 	 8a69fc68165780921bbba77da338b6932daf983c dune-pybindxi (v2.2.1-16-g8a69fc6)
 	 741e4f8e53bdd3e1b6e19d84eb22b6e3dc48526c dune-python (remotes/origin/releases/2.5)
-	 26cc8cb4161a3a51002ab2a81b8c81d2c951ee79 dune-testtools (26cc8cb)
+	 26cc8cb4161a3a51002ab2a81b8c81d2c951ee79 dune-testtools (remotes/origin/dune_xt)
 	 8fe883e99c58c9f0c2f92457d546a0ac9f5a9bf9 dune-uggrid (v2.5.2-1-g8fe883e9)
-	+1cf2465b3ce943e58771d4389cffb245d042bfa6 dune-xt-common (heads/vcsetup_bump)
-	+fae5661849439945015298af0e791e5012722679 dune-xt-data (heads/compatible_with_2.6_clang-formatted)
-	+08a67a827a02a83463691370d5d1a186a18dd43b dune-xt-functions (heads/clang_format_6)
-	+5ed09938e46a7e5b42570bb285042fa9356ce0ce dune-xt-grid (heads/compatible_with_2.6_clang-formatted)
-	+85b23137dc189ab6edc078fd68969c403a1b73b3 dune-xt-la (heads/compatible_with_2.6_clang-formatted)
-	 09d0378f616b94d68bcdd9fc6114813181849ec0 scripts (remotes/origin/HEAD)
+	+92c57fa717f1bb48bdf08de085bf4cb6beee21cb dune-xt-common (heads/dailywork_tleibner)
+	+d3a5f3e20fe36d74c4bcce82a7655af4006cedbc dune-xt-data (heads/master)
+	+aea4ef43bb0177466be2ec3cb56e3f4f5ced2c25 dune-xt-functions (heads/master)
+	+8a51b63c953466077824b3ed1177f09b2e555257 dune-xt-grid (heads/master)
+	+a7b535e1289c88579c4d7e0a0b24af5415e6ba23 dune-xt-la (heads/master)
+	 09d0378f616b94d68bcdd9fc6114813181849ec0 scripts (heads/master)
 commit = a211a5c7ba4c103fc0da57add321c5bdef7b07b5
 
 [submodule.bin]
@@ -77,7 +77,7 @@ status =
 commit = 741e4f8e53bdd3e1b6e19d84eb22b6e3dc48526c
 
 [submodule.dune-testtools]
-remote = https://github.com/dune-mirrors/dune-testtools.git
+remote = git@github.com:dune-community/dune-testtools.git
 status = 
 commit = 26cc8cb4161a3a51002ab2a81b8c81d2c951ee79
 
@@ -89,30 +89,30 @@ commit = 8fe883e99c58c9f0c2f92457d546a0ac9f5a9bf9
 [submodule.dune-xt-common]
 remote = git@github.com:dune-community/dune-xt-common.git
 status = c0b1735fab0ecbd4bb4f1eaa27cb65fe813e98f0 .vcsetup (heads/master)
-commit = 1cf2465b3ce943e58771d4389cffb245d042bfa6
+commit = 92c57fa717f1bb48bdf08de085bf4cb6beee21cb
 
 [submodule.dune-xt-data]
-remote = https://github.com/dune-community/dune-xt-data
+remote = git@github.com:dune-community/dune-xt-data
 status = c0b1735fab0ecbd4bb4f1eaa27cb65fe813e98f0 .vcsetup (heads/master)
-commit = fae5661849439945015298af0e791e5012722679
+commit = d3a5f3e20fe36d74c4bcce82a7655af4006cedbc
 
 [submodule.dune-xt-functions]
 remote = git@github.com:dune-community/dune-xt-functions.git
 status = c0b1735fab0ecbd4bb4f1eaa27cb65fe813e98f0 .vcsetup (heads/master)
-commit = 08a67a827a02a83463691370d5d1a186a18dd43b
+commit = aea4ef43bb0177466be2ec3cb56e3f4f5ced2c25
 
 [submodule.dune-xt-grid]
 remote = git@github.com:dune-community/dune-xt-grid.git
 status = c0b1735fab0ecbd4bb4f1eaa27cb65fe813e98f0 .vcsetup (heads/master)
-commit = 5ed09938e46a7e5b42570bb285042fa9356ce0ce
+commit = 8a51b63c953466077824b3ed1177f09b2e555257
 
 [submodule.dune-xt-la]
 remote = git@github.com:dune-community/dune-xt-la.git
-status = c0b1735fab0ecbd4bb4f1eaa27cb65fe813e98f0 .vcsetup (heads/master)
-commit = 85b23137dc189ab6edc078fd68969c403a1b73b3
+status = +c0b1735fab0ecbd4bb4f1eaa27cb65fe813e98f0 .vcsetup (heads/master)
+commit = a7b535e1289c88579c4d7e0a0b24af5415e6ba23
 
 [submodule.scripts]
 remote = https://github.com/wwu-numerik/scripts.git
-status = fb5ebc10e647d637c69497af2ec2560847eb2112 python/pylicense (fb5ebc1)
+status = fb5ebc10e647d637c69497af2ec2560847eb2112 python/pylicense (v0.2.0~10)
 commit = 09d0378f616b94d68bcdd9fc6114813181849ec0
 
diff --git a/dune/xt/common/vector_less.hh b/dune/xt/common/vector_less.hh
new file mode 100644
index 000000000..4b9af94d1
--- /dev/null
+++ b/dune/xt/common/vector_less.hh
@@ -0,0 +1,62 @@
+// This file is part of the dune-xt-common project:
+//   https://github.com/dune-community/dune-xt-common
+// Copyright 2009-2018 dune-xt-common developers and contributors. All rights reserved.
+// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
+//      or  GPL-2.0+ (http://opensource.org/licenses/gpl-license)
+//          with "runtime exception" (http://www.dune-project.org/license.html)
+// Authors:
+//   Tobias Leibner  (2018)
+
+#ifndef DUNE_XT_COMMON_VECTOR_LESS_HH
+#define DUNE_XT_COMMON_VECTOR_LESS_HH
+
+#include <dune/xt/common/vector.hh>
+#include <dune/xt/common/float_cmp.hh>
+
+namespace Dune {
+namespace XT {
+namespace Common {
+
+
+//! struct to be used as comparison function e.g. in a std::map<FieldVector<...>, ..., VectorLess>
+struct VectorLess
+{
+  template <class FirstVectorType, class SecondVectorType>
+  bool operator()(const FirstVectorType& a, const SecondVectorType& b) const
+  {
+    using V1 = VectorAbstraction<FirstVectorType>;
+    using V2 = VectorAbstraction<SecondVectorType>;
+    for (size_t dd = 0; dd < a.size(); ++dd) {
+      if (V1::get_entry(a, dd) < V2::get_entry(b, dd))
+        return true;
+      else if (V1::get_entry(a, dd) > V2::get_entry(b, dd))
+        return false;
+    }
+    return false;
+  }
+};
+
+//! like VectorLess but using FloatCmp::lt instead of "<"
+struct VectorFloatLess
+{
+  template <class FirstVectorType, class SecondVectorType>
+  bool operator()(const FirstVectorType& a, const SecondVectorType& b) const
+  {
+    using V1 = VectorAbstraction<FirstVectorType>;
+    using V2 = VectorAbstraction<SecondVectorType>;
+    for (size_t dd = 0; dd < a.size(); ++dd) {
+      if (XT::Common::FloatCmp::lt(V1::get_entry(a, dd), V2::get_entry(b, dd)))
+        return true;
+      else if (XT::Common::FloatCmp::gt(V1::get_entry(a, dd), V2::get_entry(b, dd)))
+        return false;
+    }
+    return false;
+  }
+};
+
+
+} // namespace Common
+} // namespace XT
+} // namespace Dune
+
+#endif // DUNE_XT_COMMON_VECTOR_LESS_HH
-- 
GitLab