|
@@ -1,7 +1,11 @@
|
|
|
#include "sort.h"
|
|
|
|
|
|
-#include <algorithm>
|
|
|
+#include "SortableRow.h"
|
|
|
#include "reorder.h"
|
|
|
+#include "IndexComparison.h"
|
|
|
+
|
|
|
+#include <cassert>
|
|
|
+#include <algorithm>
|
|
|
|
|
|
template <typename DerivedX, typename DerivedIX>
|
|
|
IGL_INLINE void igl::sort(
|
|
@@ -56,20 +60,6 @@ IGL_INLINE void igl::sort(
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// Comparison struct used by sort
|
|
|
-// http://bytes.com/topic/c/answers/132045-sort-get-index
|
|
|
-namespace igl{
|
|
|
- template<class T> struct index_cmp
|
|
|
- {
|
|
|
- index_cmp(const T arr) : arr(arr) {}
|
|
|
- bool operator()(const size_t a, const size_t b) const
|
|
|
- {
|
|
|
- return arr[a] < arr[b];
|
|
|
- }
|
|
|
- const T arr;
|
|
|
- };
|
|
|
-}
|
|
|
-
|
|
|
template <class T>
|
|
|
IGL_INLINE void igl::sort(
|
|
|
const std::vector<T> & unsorted,
|
|
@@ -87,7 +77,7 @@ IGL_INLINE void igl::sort(
|
|
|
std::sort(
|
|
|
index_map.begin(),
|
|
|
index_map.end(),
|
|
|
- igl::index_cmp<const std::vector<T>& >(unsorted));
|
|
|
+ igl::IndexLessThan<const std::vector<T>& >(unsorted));
|
|
|
|
|
|
// if not ascending then reverse
|
|
|
if(!ascending)
|
|
@@ -104,4 +94,7 @@ IGL_INLINE void igl::sort(
|
|
|
// Explicit template specialization
|
|
|
// generated by autoexplicit.sh
|
|
|
template void igl::sort<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
|
|
+template void igl::sort<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
|
|
+template void igl::sort<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> > >(std::vector<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> >, std::allocator<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> > > > const&, bool, std::vector<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> >, std::allocator<SortableRow<Eigen::Matrix<int, -1, 1, 0, -1, 1> > > >&, std::vector<unsigned long, std::allocator<unsigned long> >&);
|
|
|
+template void igl::sort<int>(std::vector<int, std::allocator<int> > const&, bool, std::vector<int, std::allocator<int> >&, std::vector<unsigned long, std::allocator<unsigned long> >&);
|
|
|
#endif
|