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.

769 lines
20 KiB

  1. //========= Copyright � 1996-2005, 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. ExecuteNTimes( 10, Warning( "CUtlMultiList overflow! (exhausted index range)\n" ) );
  332. return InvalidIndex();
  333. }
  334. // Nothing in the free list; add.
  335. // Since nothing is in the free list, m_TotalElements == total # of elements
  336. // the list knows about.
  337. if (m_MaxElementIndex == m_Memory.NumAllocated())
  338. {
  339. m_Memory.Grow();
  340. ResetDbgInfo();
  341. if ( m_MaxElementIndex >= m_Memory.NumAllocated() )
  342. {
  343. ExecuteNTimes( 10, Warning( "CUtlMultiList overflow! (exhausted memory allocator)\n" ) );
  344. return InvalidIndex();
  345. }
  346. }
  347. elem = (I)m_MaxElementIndex;
  348. ++m_MaxElementIndex;
  349. }
  350. else
  351. {
  352. elem = m_FirstFree;
  353. m_FirstFree = InternalElement(m_FirstFree).m_Next;
  354. }
  355. // Mark the element as not being in a list
  356. InternalElement(elem).m_Next = InternalElement(elem).m_Previous = elem;
  357. ++m_TotalElements;
  358. Construct( &Element(elem) );
  359. return elem;
  360. }
  361. template <class T, class I>
  362. void CUtlMultiList<T,I>::Free( I elem )
  363. {
  364. Assert( IsValidIndex(elem) && !IsInList(elem) );
  365. Destruct( &Element(elem) );
  366. InternalElement(elem).m_Next = m_FirstFree;
  367. m_FirstFree = elem;
  368. --m_TotalElements;
  369. }
  370. //-----------------------------------------------------------------------------
  371. // A test for debug mode only...
  372. //-----------------------------------------------------------------------------
  373. template <class T, class I>
  374. inline bool CUtlMultiList<T,I>::IsElementInList( ListHandle_t list, I elem ) const
  375. {
  376. if (!m_pElementList)
  377. return true;
  378. return m_pElementList[elem] == list;
  379. }
  380. //-----------------------------------------------------------------------------
  381. // list modification
  382. //-----------------------------------------------------------------------------
  383. template <class T, class I>
  384. void CUtlMultiList<T,I>::LinkBefore( ListHandle_t list, I before, I elem )
  385. {
  386. Assert( IsValidIndex(elem) && IsValidList(list) );
  387. // Unlink it if it's in the list at the moment
  388. Unlink(list, elem);
  389. ListElem_t& newElem = InternalElement(elem);
  390. // The element *after* our newly linked one is the one we linked before.
  391. newElem.m_Next = before;
  392. if (before == InvalidIndex())
  393. {
  394. // In this case, we're linking to the end of the list, so reset the tail
  395. newElem.m_Previous = m_List[list].m_Tail;
  396. m_List[list].m_Tail = elem;
  397. }
  398. else
  399. {
  400. // Here, we're not linking to the end. Set the prev pointer to point to
  401. // the element we're linking.
  402. Assert( IsInList(before) );
  403. ListElem_t& beforeElem = InternalElement(before);
  404. newElem.m_Previous = beforeElem.m_Previous;
  405. beforeElem.m_Previous = elem;
  406. }
  407. // Reset the head if we linked to the head of the list
  408. if (newElem.m_Previous == InvalidIndex())
  409. m_List[list].m_Head = elem;
  410. else
  411. InternalElement(newElem.m_Previous).m_Next = elem;
  412. // one more element baby
  413. ++m_List[list].m_Count;
  414. // Store the element into the list
  415. if (m_pElementList)
  416. m_pElementList[elem] = list;
  417. }
  418. template <class T, class I>
  419. void CUtlMultiList<T,I>::LinkAfter( ListHandle_t list, I after, I elem )
  420. {
  421. Assert( IsValidIndex(elem) );
  422. // Unlink it if it's in the list at the moment
  423. Unlink(list, elem);
  424. ListElem_t& newElem = InternalElement(elem);
  425. // The element *before* our newly linked one is the one we linked after
  426. newElem.m_Previous = after;
  427. if (after == InvalidIndex())
  428. {
  429. // In this case, we're linking to the head of the list, reset the head
  430. newElem.m_Next = m_List[list].m_Head;
  431. m_List[list].m_Head = elem;
  432. }
  433. else
  434. {
  435. // Here, we're not linking to the end. Set the next pointer to point to
  436. // the element we're linking.
  437. Assert( IsInList(after) );
  438. ListElem_t& afterElem = InternalElement(after);
  439. newElem.m_Next = afterElem.m_Next;
  440. afterElem.m_Next = elem;
  441. }
  442. // Reset the tail if we linked to the tail of the list
  443. if (newElem.m_Next == InvalidIndex())
  444. m_List[list].m_Tail = elem;
  445. else
  446. InternalElement(newElem.m_Next).m_Previous = elem;
  447. // one more element baby
  448. ++m_List[list].m_Count;
  449. // Store the element into the list
  450. if (m_pElementList)
  451. m_pElementList[elem] = list;
  452. }
  453. template <class T, class I>
  454. void CUtlMultiList<T,I>::Unlink( ListHandle_t list, I elem )
  455. {
  456. Assert( IsValidIndex(elem) && IsValidList(list) );
  457. if (IsInList(elem))
  458. {
  459. // Make sure the element is in the right list
  460. Assert( IsElementInList( list, elem ) );
  461. ListElem_t& oldElem = InternalElement(elem);
  462. // If we're the first guy, reset the head
  463. // otherwise, make our previous node's next pointer = our next
  464. if (oldElem.m_Previous != InvalidIndex())
  465. InternalElement(oldElem.m_Previous).m_Next = oldElem.m_Next;
  466. else
  467. m_List[list].m_Head = oldElem.m_Next;
  468. // If we're the last guy, reset the tail
  469. // otherwise, make our next node's prev pointer = our prev
  470. if (oldElem.m_Next != InvalidIndex())
  471. InternalElement(oldElem.m_Next).m_Previous = oldElem.m_Previous;
  472. else
  473. m_List[list].m_Tail = oldElem.m_Previous;
  474. // This marks this node as not in the list,
  475. // but not in the free list either
  476. oldElem.m_Previous = oldElem.m_Next = elem;
  477. // One less puppy
  478. --m_List[list].m_Count;
  479. // Store the element into the list
  480. if (m_pElementList)
  481. m_pElementList[elem] = m_List.InvalidIndex();
  482. }
  483. }
  484. template <class T, class I>
  485. inline void CUtlMultiList<T,I>::LinkToHead( ListHandle_t list, I elem )
  486. {
  487. LinkAfter( list, InvalidIndex(), elem );
  488. }
  489. template <class T, class I>
  490. inline void CUtlMultiList<T,I>::LinkToTail( ListHandle_t list, I elem )
  491. {
  492. LinkBefore( list, InvalidIndex(), elem );
  493. }
  494. //-----------------------------------------------------------------------------
  495. // Insertion methods; allocates and links (uses default constructor)
  496. //-----------------------------------------------------------------------------
  497. template <class T, class I>
  498. I CUtlMultiList<T,I>::InsertBefore( ListHandle_t list, I before )
  499. {
  500. // Make a new node
  501. I newNode = Alloc();
  502. if ( newNode == InvalidIndex() )
  503. return newNode;
  504. // Link it in
  505. LinkBefore( list, before, newNode );
  506. // Construct the data
  507. Construct( &Element(newNode) );
  508. return newNode;
  509. }
  510. template <class T, class I>
  511. I CUtlMultiList<T,I>::InsertAfter( ListHandle_t list, I after )
  512. {
  513. // Make a new node
  514. I newNode = Alloc();
  515. if ( newNode == InvalidIndex() )
  516. return newNode;
  517. // Link it in
  518. LinkAfter( list, after, newNode );
  519. // Construct the data
  520. Construct( &Element(newNode) );
  521. return newNode;
  522. }
  523. template <class T, class I>
  524. inline I CUtlMultiList<T,I>::AddToHead( ListHandle_t list )
  525. {
  526. return InsertAfter( list, InvalidIndex() );
  527. }
  528. template <class T, class I>
  529. inline I CUtlMultiList<T,I>::AddToTail( ListHandle_t list )
  530. {
  531. return InsertBefore( list, InvalidIndex() );
  532. }
  533. //-----------------------------------------------------------------------------
  534. // Insertion methods; allocates and links (uses copy constructor)
  535. //-----------------------------------------------------------------------------
  536. template <class T, class I>
  537. I CUtlMultiList<T,I>::InsertBefore( ListHandle_t list, I before, T const& src )
  538. {
  539. // Make a new node
  540. I newNode = Alloc();
  541. if ( newNode == InvalidIndex() )
  542. return newNode;
  543. // Link it in
  544. LinkBefore( list, before, newNode );
  545. // Construct the data
  546. CopyConstruct( &Element(newNode), src );
  547. return newNode;
  548. }
  549. template <class T, class I>
  550. I CUtlMultiList<T,I>::InsertAfter( ListHandle_t list, I after, T const& src )
  551. {
  552. // Make a new node
  553. I newNode = Alloc();
  554. if ( newNode == InvalidIndex() )
  555. return newNode;
  556. // Link it in
  557. LinkAfter( list, after, newNode );
  558. // Construct the data
  559. CopyConstruct( &Element(newNode), src );
  560. return newNode;
  561. }
  562. template <class T, class I>
  563. inline I CUtlMultiList<T,I>::AddToHead( ListHandle_t list, T const& src )
  564. {
  565. return InsertAfter( list, InvalidIndex(), src );
  566. }
  567. template <class T, class I>
  568. inline I CUtlMultiList<T,I>::AddToTail( ListHandle_t list, T const& src )
  569. {
  570. return InsertBefore( list, InvalidIndex(), src );
  571. }
  572. //-----------------------------------------------------------------------------
  573. // Removal methods
  574. //-----------------------------------------------------------------------------
  575. template <class T, class I>
  576. void CUtlMultiList<T,I>::Remove( ListHandle_t list, I elem )
  577. {
  578. if (IsInList(elem))
  579. Unlink(list, elem);
  580. Free( elem );
  581. }
  582. // Removes all items in a single list
  583. template <class T, class I>
  584. void CUtlMultiList<T,I>::RemoveAll( ListHandle_t list )
  585. {
  586. Assert( IsValidList(list) );
  587. I i = Head(list);
  588. I next;
  589. while( i != InvalidIndex() )
  590. {
  591. next = Next(i);
  592. Remove(list, i);
  593. i = next;
  594. }
  595. }
  596. template <class T, class I>
  597. void CUtlMultiList<T,I>::RemoveAll()
  598. {
  599. if (m_MaxElementIndex == 0)
  600. return;
  601. // Put everything into the free list
  602. I prev = InvalidIndex();
  603. for (int i = (int)m_MaxElementIndex; --i >= 0; )
  604. {
  605. // Invoke the destructor
  606. if (IsValidIndex((I)i))
  607. Destruct( &Element((I)i) );
  608. // next points to the next free list item
  609. InternalElement((I)i).m_Next = prev;
  610. // Indicates it's in the free list
  611. InternalElement((I)i).m_Previous = (I)i;
  612. prev = (I)i;
  613. }
  614. // First free points to the first element
  615. m_FirstFree = 0;
  616. // Clear everything else out
  617. for (I list = m_List.Head(); list != m_List.InvalidIndex(); list = m_List.Next(list) )
  618. {
  619. m_List[list].m_Head = InvalidIndex();
  620. m_List[list].m_Tail = InvalidIndex();
  621. m_List[list].m_Count = 0;
  622. }
  623. m_TotalElements = 0;
  624. }
  625. #include "tier0/memdbgoff.h"
  626. #endif // UTLMULTILIST_H