Stable Vector fully works as both Standalone and with BinSearchArrayMap
DONE
This commit is contained in:
@@ -120,14 +120,10 @@ namespace OpenVulkano
|
||||
T& operator*()
|
||||
{
|
||||
auto realIndex = m_chunk->GetRealIndex(m_index);
|
||||
return m_chunk->GetAlignedData(m_index);
|
||||
return m_chunk->GetAlignedData(realIndex);
|
||||
}
|
||||
|
||||
T* operator->()
|
||||
{
|
||||
auto realIndex = m_chunk->GetRealIndex(m_index);
|
||||
return &m_chunk->GetAlignedData(m_index);
|
||||
}
|
||||
T* operator->() { return &operator*(); }
|
||||
|
||||
Iterator& operator++()
|
||||
{
|
||||
@@ -139,8 +135,7 @@ namespace OpenVulkano
|
||||
Iterator operator++(int)
|
||||
{
|
||||
Iterator temp = *this;
|
||||
++m_index;
|
||||
MoveToNextChunk();
|
||||
++temp;
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -154,8 +149,7 @@ namespace OpenVulkano
|
||||
Iterator operator--(int)
|
||||
{
|
||||
Iterator temp = *this;
|
||||
--m_index;
|
||||
MoveToPrevChunk();
|
||||
--temp;
|
||||
return temp;
|
||||
}
|
||||
|
||||
@@ -185,37 +179,31 @@ namespace OpenVulkano
|
||||
return m_chunk != other.m_chunk || m_index != other.m_index;
|
||||
}
|
||||
|
||||
size_t GetIndex() const { return m_index; }
|
||||
size_t GetChunk() const { return m_chunk; }
|
||||
std::streamsize GetIndex() const { return m_chunk->GetRealIndex(m_index); }
|
||||
VectorChunk* GetChunk() const { return m_chunk; }
|
||||
|
||||
protected:
|
||||
void MoveToNextChunk()
|
||||
{
|
||||
while (m_chunk && !m_chunk->m_occupiedIndices[m_index])
|
||||
{
|
||||
if (m_index >= m_chunk->m_size)
|
||||
{
|
||||
m_chunk = m_chunk->m_next;
|
||||
m_index = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++m_index;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_chunk && m_index > m_chunk->m_size)
|
||||
while (m_chunk && m_index >= m_chunk->m_size)
|
||||
{
|
||||
m_index -= m_chunk->m_size;
|
||||
m_chunk = m_chunk->m_next;
|
||||
m_index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void MoveToPrevChunk() {}
|
||||
void MoveToPrevChunk()
|
||||
{
|
||||
while (m_chunk && m_index < 0)
|
||||
{
|
||||
m_index += m_chunk->m_size;
|
||||
m_chunk = m_chunk->m_prev;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
VectorChunk* m_chunk;
|
||||
size_t m_index;
|
||||
std::streamsize m_index;
|
||||
};
|
||||
|
||||
public:
|
||||
@@ -354,6 +342,8 @@ namespace OpenVulkano
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentChunk = currentChunk->m_next;
|
||||
}
|
||||
|
||||
PushBack(value);
|
||||
@@ -497,7 +487,14 @@ namespace OpenVulkano
|
||||
m_size--;
|
||||
}
|
||||
|
||||
void Remove(const Iterator& it) { Remove(it.GetIndex()); }
|
||||
void Remove(const Iterator& it)
|
||||
{
|
||||
it.GetChunk()->m_data[it.GetIndex()].~T();
|
||||
it.GetChunk()->m_occupiedIndices[it.GetIndex()] = false;
|
||||
it.GetChunk()->m_size--;
|
||||
it.GetChunk()->m_gapCount++;
|
||||
m_size--;
|
||||
}
|
||||
|
||||
T& operator[](size_t index) noexcept
|
||||
{
|
||||
@@ -531,8 +528,6 @@ namespace OpenVulkano
|
||||
m_size = 0;
|
||||
}
|
||||
|
||||
/// std version of clear
|
||||
|
||||
size_t Size() const noexcept { return m_size; }
|
||||
size_t Capacity() const noexcept { return m_capacity; }
|
||||
bool Empty() const noexcept { return m_size == 0; }
|
||||
@@ -552,7 +547,7 @@ namespace OpenVulkano
|
||||
T& front() { return Front(); }
|
||||
bool empty() const noexcept { return Empty(); }
|
||||
void clear() { Clear(); }
|
||||
void erase(const Iterator& it) { Remove(it.GetIndex()); }
|
||||
void erase(const Iterator& it) { Remove(it); }
|
||||
size_t size() const noexcept { return Size(); }
|
||||
size_t capacity() const noexcept { return Capacity(); }
|
||||
//endregion
|
||||
|
||||
Reference in New Issue
Block a user