Skip to content

v0.2.49..v0.2.50 changeset CollectionUtils.h

Garret Voltz edited this page Nov 6, 2019 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/util/CollectionUtils.h b/hoot-core/src/main/cpp/hoot/core/util/CollectionUtils.h
index c6eff97..a428312 100644
--- a/hoot-core/src/main/cpp/hoot/core/util/CollectionUtils.h
+++ b/hoot-core/src/main/cpp/hoot/core/util/CollectionUtils.h
@@ -30,6 +30,10 @@
 
 // Qt
 #include <QString>
+#include <QSet>
+
+// Std
+#include <set>
 
 namespace hoot
 {
@@ -68,6 +72,25 @@ public:
   static int numVectorItemsInCommon(const std::vector<long>& collection1,
                                     const std::vector<long>& collection2);
 
+  /**
+   * Converts a stdlib set to a Qt set
+   *
+   * @param set the set to convert
+   * @return
+   * @note std::set is ordered and QSet
+   */
+  template<typename T>
+  static QSet<T> stdSetToQSet(const std::set<T>& set)
+  {
+    // There's probably a more efficient way to do this...
+    QSet<T> qSet;
+    for (typename std::set<T>::const_iterator itr = set.begin(); itr != set.end(); ++itr)
+    {
+      qSet.insert(*itr);
+    }
+    return qSet;
+  }
+
 private:
 
   template<typename A, typename B>
Clone this wiki locally