Vector.h 872 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef ANKI_UTIL_VECTOR_H
  2. #define ANKI_UTIL_VECTOR_H
  3. #include "anki/util/Assert.h"
  4. #include "anki/util/Functions.h"
  5. #include "anki/util/Allocator.h"
  6. #include "anki/util/Memory.h"
  7. #include <vector>
  8. namespace anki {
  9. /// @addtogroup util
  10. /// @{
  11. /// @addtogroup containers
  12. /// @{
  13. template<typename T, typename Alloc = Allocator<T>>
  14. using Vector = std::vector<T, Alloc>;
  15. /// Vector of pointers. The same as the regular vector but it deallocates the
  16. /// pointers
  17. template<typename T, typename Alloc = Allocator<T>>
  18. class PtrVector: public Vector<T*, Alloc>
  19. {
  20. public:
  21. typedef Vector<T*, Alloc> Base;
  22. ~PtrVector()
  23. {
  24. for(typename Base::iterator it = Base::begin(); it != Base::end(); it++)
  25. {
  26. propperDelete(*it);
  27. }
  28. }
  29. typename Base::iterator erase(typename Base::iterator pos)
  30. {
  31. return Base::erase(pos);
  32. }
  33. };
  34. /// @}
  35. /// @}
  36. } // end namespace anki
  37. #endif