Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

771 lines
20 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Multiple linked list container class
  4. //
  5. // $Revision: $
  6. // $NoKeywords: $
  7. //=============================================================================//
  8. #ifndef UTLMULTILIST_H
  9. #define UTLMULTILIST_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. #include "utllinkedlist.h"
  14. // memdbgon must be the last include file in a .h file!!!
  15. #include "tier0/memdbgon.h"
  16. //-----------------------------------------------------------------------------
  17. // class CUtlMultiList:
  18. // description:
  19. // A lovely index-based linked list! T is the class type, I is the index
  20. // type, which usually should be an unsigned short or smaller.
  21. // This list can contain multiple lists
  22. //-----------------------------------------------------------------------------
  23. template <class T, class I>
  24. class CUtlMultiList
  25. {
  26. protected:
  27. // What the linked list element looks like
  28. struct ListElem_t
  29. {
  30. T m_Element;
  31. I m_Previous;
  32. I m_Next;
  33. };
  34. struct List_t
  35. {
  36. I m_Head;
  37. I m_Tail;
  38. I m_Count;
  39. };
  40. typedef CUtlMemory<ListElem_t> M; // Keep naming similar to CUtlLinkedList
  41. public:
  42. typedef I ListHandle_t;
  43. // constructor, destructor
  44. CUtlMultiList( int growSize = 0, int initSize = 0 );
  45. CUtlMultiList( void *pMemory, int memsize );
  46. ~CUtlMultiList( );
  47. // gets particular elements
  48. T& Element( I i );
  49. T const& Element( I i ) const;
  50. T& operator[]( I i );
  51. T const& operator[]( I i ) const;
  52. // Make sure we have a particular amount of memory
  53. void EnsureCapacity( int num );
  54. // Memory deallocation
  55. void Purge();
  56. // List Creation/deletion
  57. ListHandle_t CreateList();
  58. void DestroyList( ListHandle_t list );
  59. bool IsValidList( ListHandle_t list ) const;
  60. // Insertion methods (call default constructor)....
  61. I InsertBefore( ListHandle_t list, I before );
  62. I InsertAfter( ListHandle_t list, I after );
  63. I AddToHead( ListHandle_t list );
  64. I AddToTail( ListHandle_t list );
  65. // Insertion methods (call copy constructor)....
  66. I InsertBefore( ListHandle_t list, I before, T const& src );
  67. I InsertAfter( ListHandle_t list, I after, T const& src );
  68. I AddToHead( ListHandle_t list, T const& src );
  69. I AddToTail( ListHandle_t list, T const& src );
  70. // Removal methods
  71. void Remove( ListHandle_t list, I elem );
  72. // Removes all items in a single list
  73. void RemoveAll( ListHandle_t list );
  74. // Removes all items in all lists
  75. void RemoveAll();
  76. // Allocation/deallocation methods
  77. // NOTE: To free, it must *not* be in a list!
  78. I Alloc( );
  79. void Free( I elem );
  80. // list modification
  81. void LinkBefore( ListHandle_t list, I before, I elem );
  82. void LinkAfter( ListHandle_t list, I after, I elem );
  83. void Unlink( ListHandle_t list, I elem );
  84. void LinkToHead( ListHandle_t list, I elem );
  85. void LinkToTail( ListHandle_t list, I elem );
  86. // invalid index
  87. static I InvalidIndex() { return (I)~0; }
  88. static bool IndexInRange( int index );
  89. static size_t ElementSize() { return sizeof(ListElem_t); }
  90. // list statistics
  91. int Count( ListHandle_t list ) const;
  92. int TotalCount( ) const;
  93. I MaxElementIndex() const;
  94. // Traversing the list
  95. I Head( ListHandle_t list ) const;
  96. I Tail( ListHandle_t list ) const;
  97. I Previous( I element ) const;
  98. I Next( I element ) const;
  99. // Are nodes in a list or valid?
  100. bool IsValidIndex( I i ) const;
  101. bool IsInList( I i ) const;
  102. protected:
  103. // constructs the class
  104. void ConstructList( );
  105. // Gets at the list element....
  106. ListElem_t& InternalElement( I i ) { return m_Memory[i]; }
  107. ListElem_t const& InternalElement( I i ) const { return m_Memory[i]; }
  108. // A test for debug mode only...
  109. bool IsElementInList( ListHandle_t list, I elem ) const;
  110. // copy constructors not allowed
  111. CUtlMultiList( CUtlMultiList<T, I> const& list ) { Assert(0); }
  112. M m_Memory;
  113. CUtlLinkedList<List_t, I> m_List;
  114. I* m_pElementList;
  115. I m_FirstFree;
  116. I m_TotalElements;
  117. int m_MaxElementIndex; // The number allocated (use int so we can catch overflow)
  118. void ResetDbgInfo()
  119. {
  120. m_pElements = m_Memory.Base();
  121. #ifdef _DEBUG
  122. // Allocate space for the element list (which list is each element in)
  123. if (m_Memory.NumAllocated() > 0)
  124. {
  125. if (!m_pElementList)
  126. {
  127. m_pElementList = (I*)malloc( m_Memory.NumAllocated() * sizeof(I) );
  128. }
  129. else
  130. {
  131. m_pElementList = (I*)realloc( m_pElementList, m_Memory.NumAllocated() * sizeof(I) );
  132. }
  133. }
  134. #endif
  135. }
  136. // For debugging purposes;
  137. // it's in release builds so this can be used in libraries correctly
  138. ListElem_t *m_pElements;
  139. };
  140. //-----------------------------------------------------------------------------
  141. // constructor, destructor
  142. //-----------------------------------------------------------------------------
  143. template <class T, class I>
  144. CUtlMultiList<T,I>::CUtlMultiList( int growSize, int initSize ) :
  145. m_Memory(growSize, initSize), m_pElementList(0)
  146. {
  147. ConstructList();
  148. }
  149. template <class T, class I>
  150. CUtlMultiList<T,I>::CUtlMultiList( void* pMemory, int memsize ) :
  151. m_Memory((ListElem_t *)pMemory, memsize/sizeof(ListElem_t)), m_pElementList(0)
  152. {
  153. ConstructList();
  154. }
  155. template <class T, class I>
  156. CUtlMultiList<T,I>::~CUtlMultiList( )
  157. {
  158. RemoveAll();
  159. if (m_pElementList)
  160. free(m_pElementList);
  161. }
  162. template <class T, class I>
  163. void CUtlMultiList<T,I>::ConstructList( )
  164. {
  165. m_FirstFree = InvalidIndex();
  166. m_TotalElements = 0;
  167. m_MaxElementIndex = 0;
  168. ResetDbgInfo();
  169. }
  170. //-----------------------------------------------------------------------------
  171. // gets particular elements
  172. //-----------------------------------------------------------------------------
  173. template <class T, class I>
  174. inline T& CUtlMultiList<T,I>::Element( I i )
  175. {
  176. return m_Memory[i].m_Element;
  177. }
  178. template <class T, class I>
  179. inline T const& CUtlMultiList<T,I>::Element( I i ) const
  180. {
  181. return m_Memory[i].m_Element;
  182. }
  183. template <class T, class I>
  184. inline T& CUtlMultiList<T,I>::operator[]( I i )
  185. {
  186. return m_Memory[i].m_Element;
  187. }
  188. template <class T, class I>
  189. inline T const& CUtlMultiList<T,I>::operator[]( I i ) const
  190. {
  191. return m_Memory[i].m_Element;
  192. }
  193. //-----------------------------------------------------------------------------
  194. // list creation/destruction
  195. //-----------------------------------------------------------------------------
  196. template <class T, class I>
  197. typename CUtlMultiList<T,I>::ListHandle_t CUtlMultiList<T,I>::CreateList()
  198. {
  199. ListHandle_t l = m_List.AddToTail();
  200. m_List[l].m_Head = m_List[l].m_Tail = InvalidIndex();
  201. m_List[l].m_Count = 0;
  202. return l;
  203. }
  204. template <class T, class I>
  205. void CUtlMultiList<T,I>::DestroyList( ListHandle_t list )
  206. {
  207. Assert( IsValidList(list) );
  208. RemoveAll( list );
  209. m_List.Remove(list);
  210. }
  211. template <class T, class I>
  212. bool CUtlMultiList<T,I>::IsValidList( ListHandle_t list ) const
  213. {
  214. return m_List.IsValidIndex(list);
  215. }
  216. //-----------------------------------------------------------------------------
  217. // list statistics
  218. //-----------------------------------------------------------------------------
  219. template <class T, class I>
  220. inline int CUtlMultiList<T,I>::TotalCount() const
  221. {
  222. return m_TotalElements;
  223. }
  224. template <class T, class I>
  225. inline int CUtlMultiList<T,I>::Count( ListHandle_t list ) const
  226. {
  227. Assert( IsValidList(list) );
  228. return m_List[list].m_Count;
  229. }
  230. template <class T, class I>
  231. inline I CUtlMultiList<T,I>::MaxElementIndex() const
  232. {
  233. return m_MaxElementIndex;
  234. }
  235. //-----------------------------------------------------------------------------
  236. // Traversing the list
  237. //-----------------------------------------------------------------------------
  238. template <class T, class I>
  239. inline I CUtlMultiList<T,I>::Head(ListHandle_t list) const
  240. {
  241. Assert( IsValidList(list) );
  242. return m_List[list].m_Head;
  243. }
  244. template <class T, class I>
  245. inline I CUtlMultiList<T,I>::Tail(ListHandle_t list) const
  246. {
  247. Assert( IsValidList(list) );
  248. return m_List[list].m_Tail;
  249. }
  250. template <class T, class I>
  251. inline I CUtlMultiList<T,I>::Previous( I i ) const
  252. {
  253. Assert( IsValidIndex(i) );
  254. return InternalElement(i).m_Previous;
  255. }
  256. template <class T, class I>
  257. inline I CUtlMultiList<T,I>::Next( I i ) const
  258. {
  259. Assert( IsValidIndex(i) );
  260. return InternalElement(i).m_Next;
  261. }
  262. //-----------------------------------------------------------------------------
  263. // Are nodes in the list or valid?
  264. //-----------------------------------------------------------------------------
  265. template <class T, class I>
  266. inline bool CUtlMultiList<T,I>::IndexInRange( int index ) // Static method
  267. {
  268. // Since I is not necessarily the type returned by M (int), we need to check that M returns
  269. // indices which are representable by I. A common case is 'I === unsigned short', in which case
  270. // case CUtlMemory will have 'InvalidIndex == (int)-1' (which casts to 65535 in I), and will
  271. // happily return elements at index 65535 and above.
  272. // Do a couple of static checks here: the invalid index should be (I)~0 given how we use m_MaxElementIndex,
  273. // and 'I' should be unsigned (to avoid signed arithmetic errors for plausibly exhaustible ranges).
  274. COMPILE_TIME_ASSERT( (I)M::INVALID_INDEX == (I)~0 );
  275. COMPILE_TIME_ASSERT( ( sizeof(I) > 2 ) || ( ( (I)-1 ) > 0 ) );
  276. return ( ( (I)index == index ) && ( (I)index != InvalidIndex() ) );
  277. }
  278. template <class T, class I>
  279. inline bool CUtlMultiList<T,I>::IsValidIndex( I i ) const
  280. {
  281. // GCC warns if I is an unsigned type and we do a ">= 0" against it (since the comparison is always 0).
  282. // We get the warning even if we cast inside the expression. It only goes away if we assign to another variable.
  283. long x = i;
  284. return (i < m_MaxElementIndex) && (x >= 0) &&
  285. ((m_Memory[i].m_Previous != i) || (m_Memory[i].m_Next == i));
  286. }
  287. template <class T, class I>
  288. inline bool CUtlMultiList<T,I>::IsInList( I i ) const
  289. {
  290. // GCC warns if I is an unsigned type and we do a ">= 0" against it (since the comparison is always 0).
  291. // We get the warning even if we cast inside the expression. It only goes away if we assign to another variable.
  292. long x = i;
  293. return (i < m_MaxElementIndex) && (x >= 0) && (Previous(i) != i);
  294. }
  295. //-----------------------------------------------------------------------------
  296. // Makes sure we have enough memory allocated to store a requested # of elements
  297. //-----------------------------------------------------------------------------
  298. template< class T, class I >
  299. void CUtlMultiList<T, I>::EnsureCapacity( int num )
  300. {
  301. m_Memory.EnsureCapacity(num);
  302. ResetDbgInfo();
  303. }
  304. //-----------------------------------------------------------------------------
  305. // Deallocate memory
  306. //-----------------------------------------------------------------------------
  307. template <class T, class I>
  308. void CUtlMultiList<T,I>::Purge()
  309. {
  310. RemoveAll();
  311. m_List.Purge();
  312. m_Memory.Purge( );
  313. m_List.Purge();
  314. m_FirstFree = InvalidIndex();
  315. m_TotalElements = 0;
  316. m_MaxElementIndex = 0;
  317. ResetDbgInfo();
  318. }
  319. //-----------------------------------------------------------------------------
  320. // Node allocation/deallocation
  321. //-----------------------------------------------------------------------------
  322. template <class T, class I>
  323. I CUtlMultiList<T,I>::Alloc( )
  324. {
  325. I elem;
  326. if (m_FirstFree == InvalidIndex())
  327. {
  328. // We can overflow before the utlmemory overflows, since we have have I != int
  329. if ( !IndexInRange( m_MaxElementIndex ) )
  330. {
  331. // We rarely if ever handle alloc failure. Continuing leads to corruption.
  332. Error( "CUtlMultiList overflow! (exhausted index range)\n" );
  333. return InvalidIndex();
  334. }
  335. // Nothing in the free list; add.
  336. // Since nothing is in the free list, m_TotalElements == total # of elements
  337. // the list knows about.
  338. if (m_MaxElementIndex == m_Memory.NumAllocated())
  339. {
  340. m_Memory.Grow();
  341. ResetDbgInfo();
  342. if ( m_MaxElementIndex >= m_Memory.NumAllocated() )
  343. {
  344. // We rarely if ever handle alloc failure. Continuing leads to corruption.
  345. Error( "CUtlMultiList overflow! (exhausted memory allocator)\n" );
  346. return InvalidIndex();
  347. }
  348. }
  349. elem = (I)m_MaxElementIndex;
  350. ++m_MaxElementIndex;
  351. }
  352. else
  353. {
  354. elem = m_FirstFree;
  355. m_FirstFree = InternalElement(m_FirstFree).m_Next;
  356. }
  357. // Mark the element as not being in a list
  358. InternalElement(elem).m_Next = InternalElement(elem).m_Previous = elem;
  359. ++m_TotalElements;
  360. Construct( &Element(elem) );
  361. return elem;
  362. }
  363. template <class T, class I>
  364. void CUtlMultiList<T,I>::Free( I elem )
  365. {
  366. Assert( IsValidIndex(elem) && !IsInList(elem) );
  367. Destruct( &Element(elem) );
  368. InternalElement(elem).m_Next = m_FirstFree;
  369. m_FirstFree = elem;
  370. --m_TotalElements;
  371. }
  372. //-----------------------------------------------------------------------------
  373. // A test for debug mode only...
  374. //-----------------------------------------------------------------------------
  375. template <class T, class I>
  376. inline bool CUtlMultiList<T,I>::IsElementInList( ListHandle_t list, I elem ) const
  377. {
  378. if (!m_pElementList)
  379. return true;
  380. return m_pElementList[elem] == list;
  381. }
  382. //-----------------------------------------------------------------------------
  383. // list modification
  384. //-----------------------------------------------------------------------------
  385. template <class T, class I>
  386. void CUtlMultiList<T,I>::LinkBefore( ListHandle_t list, I before, I elem )
  387. {
  388. Assert( IsValidIndex(elem) && IsValidList(list) );
  389. // Unlink it if it's in the list at the moment
  390. Unlink(list, elem);
  391. ListElem_t& newElem = InternalElement(elem);
  392. // The element *after* our newly linked one is the one we linked before.
  393. newElem.m_Next = before;
  394. if (before == InvalidIndex())
  395. {
  396. // In this case, we're linking to the end of the list, so reset the tail
  397. newElem.m_Previous = m_List[list].m_Tail;
  398. m_List[list].m_Tail = elem;
  399. }
  400. else
  401. {
  402. // Here, we're not linking to the end. Set the prev pointer to point to
  403. // the element we're linking.
  404. Assert( IsInList(before) );
  405. ListElem_t& beforeElem = InternalElement(before);
  406. newElem.m_Previous = beforeElem.m_Previous;
  407. beforeElem.m_Previous = elem;
  408. }
  409. // Reset the head if we linked to the head of the list
  410. if (newElem.m_Previous == InvalidIndex())
  411. m_List[list].m_Head = elem;
  412. else
  413. InternalElement(newElem.m_Previous).m_Next = elem;
  414. // one more element baby
  415. ++m_List[list].m_Count;
  416. // Store the element into the list
  417. if (m_pElementList)
  418. m_pElementList[elem] = list;
  419. }
  420. template <class T, class I>
  421. void CUtlMultiList<T,I>::LinkAfter( ListHandle_t list, I after, I elem )
  422. {
  423. Assert( IsValidIndex(elem) );
  424. // Unlink it if it's in the list at the moment
  425. Unlink(list, elem);
  426. ListElem_t& newElem = InternalElement(elem);
  427. // The element *before* our newly linked one is the one we linked after
  428. newElem.m_Previous = after;
  429. if (after == InvalidIndex())
  430. {
  431. // In this case, we're linking to the head of the list, reset the head
  432. newElem.m_Next = m_List[list].m_Head;
  433. m_List[list].m_Head = elem;
  434. }
  435. else
  436. {
  437. // Here, we're not linking to the end. Set the next pointer to point to
  438. // the element we're linking.
  439. Assert( IsInList(after) );
  440. ListElem_t& afterElem = InternalElement(after);
  441. newElem.m_Next = afterElem.m_Next;
  442. afterElem.m_Next = elem;
  443. }
  444. // Reset the tail if we linked to the tail of the list
  445. if (newElem.m_Next == InvalidIndex())
  446. m_List[list].m_Tail = elem;
  447. else
  448. InternalElement(newElem.m_Next).m_Previous = elem;
  449. // one more element baby
  450. ++m_List[list].m_Count;
  451. // Store the element into the list
  452. if (m_pElementList)
  453. m_pElementList[elem] = list;
  454. }
  455. template <class T, class I>
  456. void CUtlMultiList<T,I>::Unlink( ListHandle_t list, I elem )
  457. {
  458. Assert( IsValidIndex(elem) && IsValidList(list) );
  459. if (IsInList(elem))
  460. {
  461. // Make sure the element is in the right list
  462. Assert( IsElementInList( list, elem ) );
  463. ListElem_t& oldElem = InternalElement(elem);
  464. // If we're the first guy, reset the head
  465. // otherwise, make our previous node's next pointer = our next
  466. if (oldElem.m_Previous != InvalidIndex())
  467. InternalElement(oldElem.m_Previous).m_Next = oldElem.m_Next;
  468. else
  469. m_List[list].m_Head = oldElem.m_Next;
  470. // If we're the last guy, reset the tail
  471. // otherwise, make our next node's prev pointer = our prev
  472. if (oldElem.m_Next != InvalidIndex())
  473. InternalElement(oldElem.m_Next).m_Previous = oldElem.m_Previous;
  474. else
  475. m_List[list].m_Tail = oldElem.m_Previous;
  476. // This marks this node as not in the list,
  477. // but not in the free list either
  478. oldElem.m_Previous = oldElem.m_Next = elem;
  479. // One less puppy
  480. --m_List[list].m_Count;
  481. // Store the element into the list
  482. if (m_pElementList)
  483. m_pElementList[elem] = m_List.InvalidIndex();
  484. }
  485. }
  486. template <class T, class I>
  487. inline void CUtlMultiList<T,I>::LinkToHead( ListHandle_t list, I elem )
  488. {
  489. LinkAfter( list, InvalidIndex(), elem );
  490. }
  491. template <class T, class I>
  492. inline void CUtlMultiList<T,I>::LinkToTail( ListHandle_t list, I elem )
  493. {
  494. LinkBefore( list, InvalidIndex(), elem );
  495. }
  496. //-----------------------------------------------------------------------------
  497. // Insertion methods; allocates and links (uses default constructor)
  498. //-----------------------------------------------------------------------------
  499. template <class T, class I>
  500. I CUtlMultiList<T,I>::InsertBefore( ListHandle_t list, I before )
  501. {
  502. // Make a new node
  503. I newNode = Alloc();
  504. if ( newNode == InvalidIndex() )
  505. return newNode;
  506. // Link it in
  507. LinkBefore( list, before, newNode );
  508. // Construct the data
  509. Construct( &Element(newNode) );
  510. return newNode;
  511. }
  512. template <class T, class I>
  513. I CUtlMultiList<T,I>::InsertAfter( ListHandle_t list, I after )
  514. {
  515. // Make a new node
  516. I newNode = Alloc();
  517. if ( newNode == InvalidIndex() )
  518. return newNode;
  519. // Link it in
  520. LinkAfter( list, after, newNode );
  521. // Construct the data
  522. Construct( &Element(newNode) );
  523. return newNode;
  524. }
  525. template <class T, class I>
  526. inline I CUtlMultiList<T,I>::AddToHead( ListHandle_t list )
  527. {
  528. return InsertAfter( list, InvalidIndex() );
  529. }
  530. template <class T, class I>
  531. inline I CUtlMultiList<T,I>::AddToTail( ListHandle_t list )
  532. {
  533. return InsertBefore( list, InvalidIndex() );
  534. }
  535. //-----------------------------------------------------------------------------
  536. // Insertion methods; allocates and links (uses copy constructor)
  537. //-----------------------------------------------------------------------------
  538. template <class T, class I>
  539. I CUtlMultiList<T,I>::InsertBefore( ListHandle_t list, I before, T const& src )
  540. {
  541. // Make a new node
  542. I newNode = Alloc();
  543. if ( newNode == InvalidIndex() )
  544. return newNode;
  545. // Link it in
  546. LinkBefore( list, before, newNode );
  547. // Construct the data
  548. CopyConstruct( &Element(newNode), src );
  549. return newNode;
  550. }
  551. template <class T, class I>
  552. I CUtlMultiList<T,I>::InsertAfter( ListHandle_t list, I after, T const& src )
  553. {
  554. // Make a new node
  555. I newNode = Alloc();
  556. if ( newNode == InvalidIndex() )
  557. return newNode;
  558. // Link it in
  559. LinkAfter( list, after, newNode );
  560. // Construct the data
  561. CopyConstruct( &Element(newNode), src );
  562. return newNode;
  563. }
  564. template <class T, class I>
  565. inline I CUtlMultiList<T,I>::AddToHead( ListHandle_t list, T const& src )
  566. {
  567. return InsertAfter( list, InvalidIndex(), src );
  568. }
  569. template <class T, class I>
  570. inline I CUtlMultiList<T,I>::AddToTail( ListHandle_t list, T const& src )
  571. {
  572. return InsertBefore( list, InvalidIndex(), src );
  573. }
  574. //-----------------------------------------------------------------------------
  575. // Removal methods
  576. //-----------------------------------------------------------------------------
  577. template <class T, class I>
  578. void CUtlMultiList<T,I>::Remove( ListHandle_t list, I elem )
  579. {
  580. if (IsInList(elem))
  581. Unlink(list, elem);
  582. Free( elem );
  583. }
  584. // Removes all items in a single list
  585. template <class T, class I>
  586. void CUtlMultiList<T,I>::RemoveAll( ListHandle_t list )
  587. {
  588. Assert( IsValidList(list) );
  589. I i = Head(list);
  590. I next;
  591. while( i != InvalidIndex() )
  592. {
  593. next = Next(i);
  594. Remove(list, i);
  595. i = next;
  596. }
  597. }
  598. template <class T, class I>
  599. void CUtlMultiList<T,I>::RemoveAll()
  600. {
  601. if (m_MaxElementIndex == 0)
  602. return;
  603. // Put everything into the free list
  604. I prev = InvalidIndex();
  605. for (int i = (int)m_MaxElementIndex; --i >= 0; )
  606. {
  607. // Invoke the destructor
  608. if (IsValidIndex((I)i))
  609. Destruct( &Element((I)i) );
  610. // next points to the next free list item
  611. InternalElement((I)i).m_Next = prev;
  612. // Indicates it's in the free list
  613. InternalElement((I)i).m_Previous = (I)i;
  614. prev = (I)i;
  615. }
  616. // First free points to the first element
  617. m_FirstFree = 0;
  618. // Clear everything else out
  619. for (I list = m_List.Head(); list != m_List.InvalidIndex(); list = m_List.Next(list) )
  620. {
  621. m_List[list].m_Head = InvalidIndex();
  622. m_List[list].m_Tail = InvalidIndex();
  623. m_List[list].m_Count = 0;
  624. }
  625. m_TotalElements = 0;
  626. }
  627. #include "tier0/memdbgoff.h"
  628. #endif // UTLMULTILIST_H