Tier1: implement PopAt in CUtlStack

SourceSDK doesn't contain this feature, but it has to be implemented for reworking CInputStackSystem::PopInputContext() as this has changed; the method allows for popping the provided index to element rather than following a strict push/pop order.
This commit is contained in:
Kawe Mazidjatari 2024-11-15 13:42:47 +01:00
parent f0fcb821a8
commit 18545ec422

View File

@ -63,6 +63,7 @@ public:
// Pops the stack
void Pop();
void Pop( T& oldTop );
void PopAt( int index );
void PopMultiple( int num );
// Makes sure we have enough memory allocated to store a requested # of elements
@ -292,6 +293,17 @@ void CUtlStack<T,M>::Pop( T& oldTop )
Pop();
}
template< class T, class M >
void CUtlStack<T,M>::PopAt( int index )
{
assert( m_Size > 0 );
Destruct( &Element( index ) );
for ( int i = index ; i < ( m_Size - 1 ); ++i )
Element( i ) = Element( i + 1 );
--m_Size;
}
template< class T, class M >
void CUtlStack<T,M>::PopMultiple( int num )
{