reorder.h 561 B

123456789101112131415161718192021222324
  1. #ifndef IGL_REORDER_H
  2. #define IGL_REORDER_H
  3. #include "igl_inline.h"
  4. #include <vector>
  5. namespace igl
  6. {
  7. // Act like matlab's Y = X[I] for std vectors
  8. // where I contains a vector of indices so that after,
  9. // Y[j] = X[I[j]] for index j
  10. // this implies that Y.size() == I.size()
  11. // X and Y are allowed to be the same reference
  12. template< class T >
  13. IGL_INLINE void reorder(
  14. const std::vector<T> & unordered,
  15. std::vector<size_t> const & index_map,
  16. std::vector<T> & ordered);
  17. }
  18. #ifdef IGL_HEADER_ONLY
  19. # include "reorder.cpp"
  20. #endif
  21. #endif