Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. bool CRuleIterator::Next(CContext* Context)
  2. {
  3. /* while (Pos)
  4. {
  5. CEntityIterator& Iter = m_EntityIterators.GetNextValue(Pos);
  6. Iter.Reset(Context);
  7. }*/
  8.  
  9. // кол-во сущностей
  10. size_t EntitiesCount = m_EntityIterators.GetCount();
  11.  
  12. // если в правиле нет сущностей
  13. if (EntitiesCount == 0)
  14. {
  15. // если несколько раз будет выполняться итератор(он не константный)
  16. if (!m_bSingleExecute)
  17. {
  18. m_bSingleExecute = true;
  19. return true;
  20. }
  21. else
  22. return false; // вернуть - нет следующего итератора
  23. }
  24.  
  25. // если экзмепляров нет
  26. if (m_bIsEmpty)
  27. return false; // вернуть - нет следующего итератора
  28.  
  29. size_t i = 0;
  30.  
  31. CEntityIterator* Iter = m_EntityIterators.GetAt(i);
  32.  
  33. // поиск первого included итератора
  34. while (i < EntitiesCount && !m_IncludedIterators.GetBit(i))
  35. {
  36. i++;
  37.  
  38. if (i == EntitiesCount)
  39. return false; // вернуть - нет следующего итератора
  40.  
  41. Iter = m_EntityIterators.GetAt(i);
  42. }
  43.  
  44.  
  45. if (!Iter->Next(Context))
  46. {
  47. do
  48. {
  49. if (++i >= EntitiesCount) // дошли до конца
  50. return false;
  51. Iter->Reset();
  52. if (!Iter->Next(Context))
  53. return false;
  54.  
  55. Iter = m_EntityIterators.GetAt(i);
  56. while (i < EntitiesCount && !m_IncludedIterators.GetBit(i))
  57. {
  58. i++;
  59.  
  60. if (i == EntitiesCount)
  61. return false;
  62.  
  63. Iter = m_EntityIterators.GetAt(i);
  64. }
  65.  
  66.  
  67. } while (!Iter->Next(Context));
  68.  
  69. // если список экземпляров сущностей был изменен
  70. if (m_bReInit)
  71. {
  72. while (++i < EntitiesCount)
  73. {
  74. CEntityIterator* Iter = m_EntityIterators.GetAt(i);
  75. if (!m_IncludedIterators.GetBit(i))
  76. continue;
  77.  
  78. Iter->Current(Context);
  79. }
  80. }
  81. }
  82.  
  83. m_bReInit = false;
  84. return true;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement