reorder.h 595 B

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