reorder.cpp 801 B

123456789101112131415161718192021222324
  1. #include "reorder.h"
  2. // This implementation is O(n), but also uses O(n) extra memory
  3. template< class T >
  4. IGL_INLINE void igl::reorder(
  5. const std::vector<T> & unordered,
  6. std::vector<size_t> const & index_map,
  7. std::vector<T> & ordered)
  8. {
  9. // copy for the reorder according to index_map, because unsorted may also be
  10. // sorted
  11. std::vector<T> copy = unordered;
  12. ordered.resize(index_map.size());
  13. for(int i = 0; i<(int)index_map.size();i++)
  14. {
  15. ordered[i] = copy[index_map[i]];
  16. }
  17. }
  18. #ifndef IGL_HEADER_ONLY
  19. // Explicit template specialization
  20. // generated by autoexplicit.sh
  21. template void igl::reorder<double>(std::vector<double, std::allocator<double> > const&, std::vector<unsigned long, std::allocator<unsigned long> > const&, std::vector<double, std::allocator<double> >&);
  22. #endif