mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 20:16:10 +08:00
Correct compile errors in CUtlLeanVector & CUtlLinkedList
This commit is contained in:
@ -316,7 +316,7 @@ inline CUtlLeanVectorFixedGrowableBase<T, N, I, A>::CUtlLeanVectorFixedGrowableB
|
||||
|
||||
template< class T, size_t N, class I, class A >
|
||||
inline CUtlLeanVectorFixedGrowableBase<T, N, I, A>::CUtlLeanVectorFixedGrowableBase( T *pMemory, I allocationCount, I numElements ) :
|
||||
m_nCount( numElements ), m_nAllocated( allocationCount | EXTERNAL_BUFFER_MARKER ), m_pElements( pMemory )
|
||||
m_nAllocCount( numElements ), m_nAllocAllocated( allocationCount | EXTERNAL_BUFFER_MARKER ), m_pElements( pMemory )
|
||||
{
|
||||
}
|
||||
|
||||
@ -474,7 +474,10 @@ public:
|
||||
|
||||
// Is element index valid?
|
||||
bool IsValidIndex( int i ) const;
|
||||
static int InvalidIndex();
|
||||
|
||||
// Specify the invalid ('null') index that we'll only return on failure
|
||||
static const I INVALID_INDEX = (I)-1; // For use with COMPILE_TIME_ASSERT
|
||||
static I InvalidIndex() { return INVALID_INDEX; }
|
||||
|
||||
// Adds an element, uses default constructor
|
||||
T* AddToTailGetPtr();
|
||||
@ -611,15 +614,6 @@ inline bool CUtlLeanVectorImpl<B, T, I>::IsValidIndex( int i ) const
|
||||
return (i >= 0) && (i < this->m_nCount);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Returns in invalid index
|
||||
//-----------------------------------------------------------------------------
|
||||
template< class B, class T, class I >
|
||||
inline int CUtlLeanVectorImpl<B, T, I>::InvalidIndex()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Adds an element, uses default constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "utlblockmemory.h"
|
||||
#include "tier0/dbg.h"
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
// define to enable asserts griping about things you shouldn't be doing with multilists
|
||||
// #define MULTILIST_PEDANTIC_ASSERTS 1
|
||||
|
||||
@ -41,6 +43,8 @@
|
||||
template <class T, class I>
|
||||
struct UtlLinkedListElem_t
|
||||
{
|
||||
UtlLinkedListElem_t() {}
|
||||
|
||||
T m_Element;
|
||||
I m_Previous;
|
||||
I m_Next;
|
||||
@ -80,8 +84,6 @@ public:
|
||||
// Make sure we have a particular amount of memory
|
||||
void EnsureCapacity( int num );
|
||||
|
||||
void SetGrowSize( int growSize );
|
||||
|
||||
// Memory deallocation
|
||||
void Purge();
|
||||
|
||||
@ -159,7 +161,7 @@ protected:
|
||||
ListElem_t const& InternalElement( I i ) const { return m_Memory[i]; }
|
||||
|
||||
// copy constructors not allowed
|
||||
CUtlLinkedList( CUtlLinkedList<T, S, ML, I, M> const& list ) { Assert(0); }
|
||||
CUtlLinkedList( CUtlLinkedList<T, S, ML, I, M> const& list ) : m_LastAlloc( 0 ) { Assert(0); }
|
||||
|
||||
M m_Memory;
|
||||
I m_Head;
|
||||
@ -370,14 +372,6 @@ void CUtlLinkedList<T,S,ML,I,M>::EnsureCapacity( int num )
|
||||
m_Memory.EnsureCapacity(num);
|
||||
}
|
||||
|
||||
template< class T, class S, bool ML, class I, class M >
|
||||
void CUtlLinkedList<T,S,ML,I,M>::SetGrowSize( int growSize )
|
||||
{
|
||||
RemoveAll();
|
||||
m_Memory.Init( growSize );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Deallocate memory
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -399,11 +393,14 @@ void CUtlLinkedList<T,S,ML,I,M>::Purge()
|
||||
template<class T, class S, bool ML, class I, class M>
|
||||
void CUtlLinkedList<T,S,ML,I,M>::PurgeAndDeleteElements()
|
||||
{
|
||||
I iNext;
|
||||
for( I i=Head(); i != InvalidIndex(); i=iNext )
|
||||
if constexpr (std::is_pointer_v<T>)
|
||||
{
|
||||
iNext = Next(i);
|
||||
delete Element(i);
|
||||
I iNext;
|
||||
for(I i=Head(); i != InvalidIndex(); i=iNext)
|
||||
{
|
||||
iNext = Next( i );
|
||||
delete Element( i );
|
||||
}
|
||||
}
|
||||
|
||||
Purge();
|
||||
@ -432,7 +429,7 @@ I CUtlLinkedList<T,S,ML,I,M>::AllocInternal( bool multilist )
|
||||
if ( !m_Memory.IsValidIterator( it ) )
|
||||
{
|
||||
MEM_ALLOC_CREDIT_CLASS();
|
||||
m_Memory.Grow();
|
||||
m_Memory.AddToTailGetPtr();
|
||||
|
||||
it = m_Memory.IsValidIterator( m_LastAlloc ) ? m_Memory.Next( m_LastAlloc ) : m_Memory.First();
|
||||
|
||||
|
Reference in New Issue
Block a user