MVKVector: Make this more amenable to the standard algorithms.

This commit is contained in:
Chip Davis 2019-04-03 11:46:04 -05:00
parent 43f97113b6
commit 4591cac69b
2 changed files with 9 additions and 5 deletions

View File

@ -74,7 +74,7 @@ template<class Type> class MVKVector
mvk_vector_allocator_base<Type> *alc_ptr; mvk_vector_allocator_base<Type> *alc_ptr;
public: public:
class iterator class iterator : public std::iterator<std::forward_iterator_tag, Type>
{ {
const MVKVector *vector; const MVKVector *vector;
size_t index; size_t index;
@ -99,6 +99,8 @@ public:
}; };
public: public:
typedef Type value_type;
MVKVector() = delete; MVKVector() = delete;
MVKVector( mvk_vector_allocator_base<Type> *a ) : alc_ptr{ a } { } MVKVector( mvk_vector_allocator_base<Type> *a ) : alc_ptr{ a } { }
virtual ~MVKVector() { } virtual ~MVKVector() { }
@ -137,8 +139,7 @@ template<class Type> class MVKVector<Type *>
{ {
mvk_vector_allocator_base<Type*> *alc_ptr; mvk_vector_allocator_base<Type*> *alc_ptr;
public: class iterator : public std::iterator<std::forward_iterator_tag, Type*>
class iterator
{ {
const MVKVector *vector; const MVKVector *vector;
size_t index; size_t index;
@ -163,6 +164,8 @@ public:
}; };
public: public:
typedef Type* value_type;
MVKVector() = delete; MVKVector() = delete;
MVKVector( mvk_vector_allocator_base<Type*> *a ) : alc_ptr{ a } { } MVKVector( mvk_vector_allocator_base<Type*> *a ) : alc_ptr{ a } { }
virtual ~MVKVector() { } virtual ~MVKVector() { }
@ -203,7 +206,7 @@ template<class Type, typename Allocator = mvk_vector_allocator_default<Type>> cl
Allocator alc; Allocator alc;
public: public:
class iterator class iterator : public std::iterator<std::forward_iterator_tag, Type>
{ {
const MVKVectorImpl *vector; const MVKVectorImpl *vector;
size_t index; size_t index;
@ -635,7 +638,7 @@ template<class Type, typename Allocator> class MVKVectorImpl<Type*, Allocator> :
Allocator alc; Allocator alc;
public: public:
class iterator class iterator : public std::iterator<std::forward_iterator_tag, Type*>
{ {
MVKVectorImpl *vector; MVKVectorImpl *vector;
size_t index; size_t index;

View File

@ -44,6 +44,7 @@ template<typename T>
class mvk_vector_allocator_base class mvk_vector_allocator_base
{ {
public: public:
typedef T value_type;
T *ptr; T *ptr;
size_t num_elements_used; size_t num_elements_used;