Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool CRuleIterator::Next(CContext* Context)
- {
- /* while (Pos)
- {
- CEntityIterator& Iter = m_EntityIterators.GetNextValue(Pos);
- Iter.Reset(Context);
- }*/
- // кол-во сущностей
- size_t EntitiesCount = m_EntityIterators.GetCount();
- // если в правиле нет сущностей
- if (EntitiesCount == 0)
- {
- // если несколько раз будет выполняться итератор(он не константный)
- if (!m_bSingleExecute)
- {
- m_bSingleExecute = true;
- return true;
- }
- else
- return false; // вернуть - нет следующего итератора
- }
- // если экзмепляров нет
- if (m_bIsEmpty)
- return false; // вернуть - нет следующего итератора
- size_t i = 0;
- CEntityIterator* Iter = m_EntityIterators.GetAt(i);
- // поиск первого included итератора
- while (i < EntitiesCount && !m_IncludedIterators.GetBit(i))
- {
- i++;
- if (i == EntitiesCount)
- return false; // вернуть - нет следующего итератора
- Iter = m_EntityIterators.GetAt(i);
- }
- if (!Iter->Next(Context))
- {
- do
- {
- if (++i >= EntitiesCount) // дошли до конца
- return false;
- Iter->Reset();
- if (!Iter->Next(Context))
- return false;
- Iter = m_EntityIterators.GetAt(i);
- while (i < EntitiesCount && !m_IncludedIterators.GetBit(i))
- {
- i++;
- if (i == EntitiesCount)
- return false;
- Iter = m_EntityIterators.GetAt(i);
- }
- } while (!Iter->Next(Context));
- // если список экземпляров сущностей был изменен
- if (m_bReInit)
- {
- while (++i < EntitiesCount)
- {
- CEntityIterator* Iter = m_EntityIterators.GetAt(i);
- if (!m_IncludedIterators.GetBit(i))
- continue;
- Iter->Current(Context);
- }
- }
- }
- m_bReInit = false;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement