min_size.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #include "min_size.h"
  9. template <typename T>
  10. IGL_INLINE int igl::min_size(const std::vector<T> & V)
  11. {
  12. int min_size = -1;
  13. for(
  14. typename std::vector<T>::const_iterator iter = V.begin();
  15. iter != V.end();
  16. iter++)
  17. {
  18. int size = (int)iter->size();
  19. // have to handle base case
  20. if(min_size == -1)
  21. {
  22. min_size = size;
  23. }else{
  24. min_size = (min_size < size ? min_size : size);
  25. }
  26. }
  27. return min_size;
  28. }
  29. #ifdef IGL_STATIC_LIBRARY
  30. // Explicit template specialization
  31. // generated by autoexplicit.sh
  32. template int igl::min_size<std::vector<unsigned int, std::allocator<unsigned int> > >(std::vector<std::vector<unsigned int, std::allocator<unsigned int> >, std::allocator<std::vector<unsigned int, std::allocator<unsigned int> > > > const&);
  33. // generated by autoexplicit.sh
  34. template int igl::min_size<std::vector<int, std::allocator<int> > >(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&);
  35. // generated by autoexplicit.sh
  36. template int igl::min_size<std::vector<double, std::allocator<double> > >(std::vector<std::vector<double, std::allocator<double> >, std::allocator<std::vector<double, std::allocator<double> > > > const&);
  37. template int igl::min_size<std::vector<bool, std::allocator<bool> > >(std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > > const&);
  38. template int igl::min_size<std::vector<float, std::allocator<float> > >(std::vector<std::vector<float, std::allocator<float> >, std::allocator<std::vector<float, std::allocator<float> > > > const&);
  39. #endif