73 lines
1.3 KiB
C++
73 lines
1.3 KiB
C++
|
|
#include <Entities/EntityView.h>
|
|
#include <Entities/Entity.h>
|
|
#include <utility.h>
|
|
|
|
EntityView::EntityView(index_t start, index_t size)
|
|
: m_start(start)
|
|
, m_size(size)
|
|
{ }
|
|
|
|
Entity EntityView::operator[](index_t index) const
|
|
{
|
|
return Entity(m_start + index);
|
|
}
|
|
|
|
//non-const iterator
|
|
EntityView::iterator::iterator(index_t index)
|
|
: m_currentEntity(index)
|
|
{ }
|
|
|
|
EntityView::iterator& EntityView::iterator::operator++()
|
|
{
|
|
m_currentEntity++;
|
|
return *this;
|
|
}
|
|
|
|
EntityView::iterator EntityView::iterator::operator++(int)
|
|
{
|
|
m_currentEntity++;
|
|
return m_currentEntity - 1;
|
|
}
|
|
|
|
EntityView::iterator& EntityView::iterator::operator--()
|
|
{
|
|
m_currentEntity--;
|
|
return *this;
|
|
}
|
|
|
|
EntityView::iterator EntityView::iterator::operator--(int)
|
|
{
|
|
m_currentEntity--;
|
|
return m_currentEntity + 1;
|
|
}
|
|
|
|
Entity EntityView::iterator::operator*()
|
|
{
|
|
return m_currentEntity;
|
|
}
|
|
|
|
Entity EntityView::iterator::operator[](int index)
|
|
{
|
|
return m_currentEntity + index;
|
|
}
|
|
|
|
bool EntityView::iterator::operator==(iterator other)
|
|
{
|
|
return m_currentEntity == other.m_currentEntity;
|
|
}
|
|
|
|
bool EntityView::iterator::operator!=(iterator other)
|
|
{
|
|
return m_currentEntity != other.m_currentEntity;
|
|
}
|
|
|
|
EntityView::iterator EntityView::begin()
|
|
{
|
|
return iterator(m_start);
|
|
}
|
|
|
|
EntityView::iterator EntityView::end()
|
|
{
|
|
return iterator(m_start + m_size);
|
|
} |