5template <
typename T, TINT MaxSize>
16 : m_iIndex( 0 ), m_pVector( a_pVector ) {}
18 : m_iIndex( a_iIndex ), m_pVector( a_pVector ) {}
20 : m_iIndex( a_rOther.m_iIndex ), m_pVector( a_rOther.m_pVector ) {}
29 return &m_pVector->At( m_iIndex );
32 const T*
Get() const noexcept
34 return &m_pVector->At( m_iIndex );
39 return m_pVector->At( m_iIndex );
44 return m_pVector->At( m_iIndex );
66 operator const T*()
const
93 return a_rOther.m_pVector == m_pVector && a_rOther.m_iIndex == m_iIndex;
98 return a_rOther.m_pVector == m_pVector && a_rOther.m_iIndex > m_iIndex;
103 return a_rOther.m_pVector == m_pVector && a_rOther.m_iIndex >= m_iIndex;
108 return a_rOther.m_pVector == m_pVector && a_rOther.m_iIndex < m_iIndex;
113 return a_rOther.m_pVector == m_pVector && a_rOther.m_iIndex <= m_iIndex;
144 m_iIndex = a_rOther.m_iIndex;
145 m_pVector = a_rOther.m_pVector;
151 TASSERT( m_iIndex + a_uiValue < m_pVector->
Size() );
152 return Iterator( m_iIndex + a_uiValue, m_pVector );
157 TASSERT( m_iIndex - a_uiValue < m_pVector->
Size() );
158 return Iterator( m_iIndex - a_uiValue, m_pVector );
163 TASSERT( m_iIndex + a_uiValue < m_pVector->
Size() );
164 m_iIndex += a_uiValue;
170 TASSERT( m_iIndex - a_uiValue < m_pVector->
Size() );
171 m_iIndex -= a_uiValue;
196 InsertGap( a_itInsertBefore.
Index(), 1 );
204 InsertGap( a_itInsertAfter.
Index() + 1, 1 );
210 template <
class... Args>
214 TConstruct<T>( &AtUnsafe( m_iNumElements++ ), std::forward<Args>( args )... );
216 return Iterator( m_iNumElements - 1,
this );
224 return Iterator( m_iNumElements - 1,
this );
230 AtUnsafe( --m_iNumElements ).~T();
250 for ( i = 0; i < a_rcCopyFrom.
Size(); i++ )
257 for ( ; i <
Size(); i++ )
263 m_iNumElements = a_rcCopyFrom.
Size();
268 for (
auto it =
Begin(); it !=
End(); it++ )
270 if ( it.Value() == a_rValue )
281 TASSERT( uiItemIndex < m_iNumElements );
283 AtUnsafe( uiItemIndex ).~T();
285 if ( uiItemIndex + 1 <
Size() )
287 for (
TINT i = uiItemIndex + 1; i <
Size(); i++ )
289 TConstruct<T>( &AtUnsafe( i - 1 ), std::move( AtUnsafe( i ) ) );
300 auto it =
Find( a_rcItem );
310 TASSERT( uiItemIndex < m_iNumElements );
319 auto it =
Find( a_rcItem );
327 return m_iNumElements;
349 return Iterator( m_iNumElements - 1,
this );
359 return Iterator( m_iNumElements,
this );
364 TASSERT( a_iIndex < m_iNumElements );
365 return *(T*)( m_aBuffer + a_iIndex *
sizeof( T ) );
370 TASSERT( a_iIndex < m_iNumElements );
371 return *(
const T*)( m_aBuffer + a_iIndex *
sizeof( T ) );
376 return At( a_iIndex );
381 return At( a_iIndex );
387 return *( (T*)( m_aBuffer ) + a_iIndex );
392 return *( (T*)( m_aBuffer ) + a_iIndex );
399 if ( m_iNumElements > a_iGapAt )
405 TUtil::MemMove( &AtUnsafe( a_iGapAt + a_iGapSize ), &AtUnsafe( a_iGapAt ), ( m_iNumElements - a_iGapAt ) *
sizeof( T ) );
410 for (
TINT i = m_iNumElements - 1, k = i + a_iGapSize; i >= a_iGapAt; i--, k-- )
418 m_iNumElements += a_iGapSize;
423 TBYTE m_aBuffer[ MaxSize *
sizeof( T ) ];
TFORCEINLINE T * TConstruct(T *a_pMemory, Args &&... args)
Constructs an object in place.
#define TOSHI_NAMESPACE_START
#define TOSHI_NAMESPACE_END
void FindAndErase(const T &a_rcItem)
Iterator InsertAfter(Iterator a_itInsertAfter, const T &a_rcItem=T())
void Copy(const T2Vector< T, MaxSize > &a_rcCopyFrom)
Iterator PushBack(const T &item=T())
T & operator[](TINT a_iIndex)
const T & At(TINT a_iIndex) const
constexpr TINT Capacity() const
void Erase(const Iterator &a_rIterator)
Iterator EmplaceBack(Args &&... args)
constexpr Iterator Begin()
Iterator Find(const T &a_rValue)
void FindAndEraseFast(const T &a_rcItem)
const T & operator[](TINT a_iIndex) const
static constexpr TINT CAPACITY
Iterator InsertBefore(Iterator a_itInsertBefore, const T &a_rcItem=T())
void EraseFast(Iterator &a_rIterator)
constexpr Iterator & operator=(const Iterator &a_rOther) noexcept
const T & Value() const noexcept
const T * Get() const noexcept
TBOOL operator<(const Iterator &a_rOther) const noexcept
constexpr Iterator & operator++() noexcept
T * operator->() noexcept
constexpr Iterator(T2Vector *a_pVector)
constexpr Iterator & operator--() noexcept
TBOOL operator>(const Iterator &a_rOther) const noexcept
Iterator operator-(TINT a_uiValue) const noexcept
const T & operator*() const noexcept
const T * operator->() const noexcept
constexpr Iterator(const Iterator &a_rOther)
Iterator & operator+=(TINT a_uiValue) const noexcept
constexpr TINT Index() const noexcept
TBOOL operator<=(const Iterator &a_rOther) const noexcept
constexpr Iterator(TINT a_iIndex, T2Vector *a_pVector)
Iterator operator+(TINT a_uiValue) const noexcept
Iterator & operator-=(TINT a_uiValue) const noexcept
TBOOL operator==(const Iterator &a_rOther) const noexcept
constexpr Iterator operator--(TINT) noexcept
TBOOL operator>=(const Iterator &a_rOther) const noexcept
constexpr Iterator operator++(TINT) noexcept
static void * MemMove(void *dst, const void *src, TSIZE size)