reorder.h 614 B

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