PriorityVector.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. ** Command & Conquer Generals(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : WWAudio.h *
  23. * *
  24. * $Archive:: /Commando/Code/WWAudio/PriorityVector.h $Modtime:: 7/02/99 11:43a $*
  25. * *
  26. * $Revision:: 2 $*
  27. * *
  28. *---------------------------------------------------------------------------------------------*
  29. * Functions: *
  30. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  31. #if defined(_MSC_VER)
  32. #pragma once
  33. #endif
  34. #ifndef __PRIORITY_VECTOR_H
  35. #define __PRIORITY_VECTOR_H
  36. #include "Vector.H"
  37. ////////////////////////////////////////////////////////////////////
  38. //
  39. // PriorityVectorClass
  40. //
  41. ////////////////////////////////////////////////////////////////////
  42. template<class T>
  43. class PriorityVectorClass : public DynamicVectorClass<T>
  44. {
  45. public:
  46. virtual bool Process_Head (T &object);
  47. virtual bool Add_Low (T const &object);
  48. virtual bool Add_High (T const &object);
  49. /*PriorityVectorClass<T> & operator= (PriorityVectorClass<T> const & rvalue) {
  50. DynamicVectorClass<T>::operator= (rvalue);
  51. return(*t8his);
  52. }*/
  53. };
  54. ////////////////////////////////////////////////////////////////////
  55. //
  56. // Process_Head
  57. //
  58. ////////////////////////////////////////////////////////////////////
  59. template <class T>
  60. __inline bool PriorityVectorClass<T>::Process_Head (T &object)
  61. {
  62. bool retval = false;
  63. if (Vector != NULL) {
  64. // Pass the object back to the caller
  65. object = Vector[0];
  66. //
  67. // Move the head object to the end of the list
  68. //
  69. for (int index = 1; index < ActiveCount; index ++) {
  70. Vector[index - 1] = Vector[index];
  71. }
  72. Vector[ActiveCount - 1] = object;
  73. // Success!
  74. retval = true;
  75. }
  76. return retval;
  77. }
  78. ////////////////////////////////////////////////////////////////////
  79. //
  80. // Add_Low
  81. //
  82. ////////////////////////////////////////////////////////////////////
  83. template <class T>
  84. __inline bool PriorityVectorClass<T>::Add_Low (T const &object)
  85. {
  86. return DynamicVectorClass<T>::Add (object);
  87. }
  88. ////////////////////////////////////////////////////////////////////
  89. //
  90. // Add_High
  91. //
  92. ////////////////////////////////////////////////////////////////////
  93. template <class T>
  94. __inline bool PriorityVectorClass<T>::Add_High (T const &object)
  95. {
  96. return DynamicVectorClass<T>::Add_Head (object);
  97. }
  98. #endif //__PRIORITY_VECTOR_H