113 lines
2.2 KiB
C++
113 lines
2.2 KiB
C++
#pragma once
|
|
|
|
//#include "SwapBackVector.hpp"
|
|
#include <Entities/Entity.h>
|
|
#include <cassert>
|
|
//#include <cstdint>
|
|
//#include <cstddef>
|
|
//#include <iterator>
|
|
|
|
template<typename SwapBackVector>
|
|
class SwapBackVectorIterator
|
|
{
|
|
public:
|
|
using data_type = typename SwapBackVector::data_type;
|
|
using pointer = data_type*;
|
|
using reference = data_type&;
|
|
|
|
public:
|
|
SwapBackVectorIterator(pointer ptr)
|
|
: m_ptr(ptr)
|
|
{}
|
|
|
|
SwapBackVectorIterator& operator++()
|
|
{
|
|
m_ptr++;
|
|
return *this;
|
|
}
|
|
|
|
SwapBackVectorIterator operator++(int)
|
|
{
|
|
SwapBackVectorIterator it = *this;
|
|
++(*this);
|
|
return it;
|
|
}
|
|
|
|
SwapBackVectorIterator& operator--()
|
|
{
|
|
m_ptr--;
|
|
return *this;
|
|
}
|
|
|
|
SwapBackVectorIterator operator--(int)
|
|
{
|
|
SwapBackVectorIterator it = *this;
|
|
--(*this);
|
|
return it;
|
|
}
|
|
|
|
reference operator[](int index) { return m_ptr[index]; }
|
|
|
|
pointer operator->() { return m_ptr; }
|
|
|
|
reference operator*() { return *m_ptr; }
|
|
|
|
bool operator==(const SwapBackVectorIterator& rhs) { return m_ptr == rhs.m_ptr; }
|
|
bool operator!=(const SwapBackVectorIterator& rhs) { return !(m_ptr == rhs.m_ptr); }
|
|
private:
|
|
data_type* m_ptr;
|
|
};
|
|
|
|
|
|
|
|
template<typename SwapBackVector>
|
|
class SwapBackVectorConstIterator
|
|
{
|
|
public:
|
|
using data_type = typename SwapBackVector::data_type;
|
|
using pointer = const data_type*;
|
|
using reference = const data_type&;
|
|
|
|
public:
|
|
SwapBackVectorConstIterator(pointer ptr)
|
|
: m_ptr(ptr)
|
|
{}
|
|
|
|
SwapBackVectorConstIterator& operator++()
|
|
{
|
|
m_ptr++;
|
|
return *this;
|
|
}
|
|
|
|
SwapBackVectorConstIterator operator++(int)
|
|
{
|
|
SwapBackVectorConstIterator it = *this;
|
|
++(*this);
|
|
return it;
|
|
}
|
|
|
|
SwapBackVectorConstIterator& operator--()
|
|
{
|
|
m_ptr--;
|
|
return *this;
|
|
}
|
|
|
|
SwapBackVectorConstIterator operator--(int)
|
|
{
|
|
SwapBackVectorConstIterator it = *this;
|
|
--(*this);
|
|
return it;
|
|
}
|
|
|
|
reference operator[](int index) { return m_ptr[index]; }
|
|
|
|
pointer operator->() { return m_ptr; }
|
|
|
|
reference operator*() { return *m_ptr; }
|
|
|
|
bool operator==(const SwapBackVectorConstIterator& rhs) { return m_ptr == rhs.m_ptr; }
|
|
bool operator!=(const SwapBackVectorConstIterator& rhs) { return !(m_ptr == rhs.m_ptr); }
|
|
private:
|
|
data_type* m_ptr;
|
|
};
|