From fdffa22054694fc7ae448038141587f53e50675c Mon Sep 17 00:00:00 2001 From: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com> Date: Sat, 2 Aug 2025 16:32:22 +0300 Subject: [PATCH] Add CUtlLeanVector::Swap method --- public/tier1/utlleanvector.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/public/tier1/utlleanvector.h b/public/tier1/utlleanvector.h index 8d90275e..f7dc7141 100644 --- a/public/tier1/utlleanvector.h +++ b/public/tier1/utlleanvector.h @@ -45,6 +45,8 @@ public: T* Base(); const T* Base() const; + void Swap( CUtlLeanVectorBase &mem ); + // Makes sure we have enough memory allocated to store a requested # of elements void EnsureCapacity( int num, bool force = false ); @@ -113,6 +115,17 @@ inline const T* CUtlLeanVectorBase::Base() const return NumAllocated() ? m_pElements : nullptr; } +//----------------------------------------------------------------------------- +// Fast swap +//----------------------------------------------------------------------------- +template< class T, class I, class A > +void CUtlLeanVectorBase::Swap( CUtlLeanVectorBase &vec ) +{ + V_swap( m_nCount, vec.m_nCount ); + V_swap( m_nAllocated, vec.m_nAllocated ); + V_swap( m_pElements, vec.m_pElements ); +} + //----------------------------------------------------------------------------- // Attaches the buffer to external memory.... //-----------------------------------------------------------------------------