<commit_before>#include "ORDocumentIterator.h"
#include "NOTDocumentIterator.h"

using namespace std;
using namespace sf1r;

ORDocumentIterator::ORDocumentIterator()
        :pDocIteratorQueue_(NULL)
        ,hasNot_(false)
        ,currDocOfNOTIter_(MAX_DOC_ID)
        ,initNOTIterator_(false)
        ,pNOTDocIterator_(NULL)
{
}

ORDocumentIterator::~ORDocumentIterator()
{
    for (vector<DocumentIterator*>::iterator iter = docIteratorList_.begin(); iter != docIteratorList_.end(); ++iter)
    {
        if(*iter)
            delete *iter;
    }

    if (pNOTDocIterator_)
        delete pNOTDocIterator_;

    if (pDocIteratorQueue_)
        delete pDocIteratorQueue_;
}

void ORDocumentIterator::initDocIteratorQueue()
{
    if (docIteratorList_.size() < 1)
        return;
    pDocIteratorQueue_ = new DocumentIteratorQueue(docIteratorList_.size());
    DocumentIterator* pDocIterator;
    vector<DocumentIterator*>::iterator iter = docIteratorList_.begin();
    while (iter != docIteratorList_.end())
    {
        pDocIterator = (*iter);
        if (pDocIterator)
        {
            pDocIterator->setCurrent(false);
            if(pDocIterator->next())
                pDocIteratorQueue_->insert(pDocIterator);
           else
           {
               iter = docIteratorList_.erase(iter);
               delete pDocIterator;
               continue;
           }
        }
        iter ++;
    }
}

void ORDocumentIterator::add(DocumentIterator* pDocIterator)
{
    if (pDocIterator->isNot())
    {
        hasNot_ = true;
        if (NULL == pNOTDocIterator_)
            pNOTDocIterator_ = new NOTDocumentIterator();
        pNOTDocIterator_->add(pDocIterator);
    }
    else
        docIteratorList_.push_back(pDocIterator);
}

bool ORDocumentIterator::next()<commit_msg>revise commit <PASSWORD>, TermDocIterator should not be erased since it should be kept consist with RankDocumentProperties during scoring<commit_after>#include "ORDocumentIterator.h"
#include "NOTDocumentIterator.h"

using namespace std;
using namespace sf1r;

ORDocumentIterator::ORDocumentIterator()
        :pDocIteratorQueue_(NULL)
        ,hasNot_(false)
        ,currDocOfNOTIter_(MAX_DOC_ID)
        ,initNOTIterator_(false)
        ,pNOTDocIterator_(NULL)
{
}

ORDocumentIterator::~ORDocumentIterator()
{
    for (vector<DocumentIterator*>::iterator iter = docIteratorList_.begin(); iter != docIteratorList_.end(); ++iter)
    {
        if(*iter)
            delete *iter;
    }

    if (pNOTDocIterator_)
        delete pNOTDocIterator_;

    if (pDocIteratorQueue_)
        delete pDocIteratorQueue_;
}

void ORDocumentIterator::initDocIteratorQueue()
{
    if (docIteratorList_.size() < 1)
        return;
    pDocIteratorQueue_ = new DocumentIteratorQueue(docIteratorList_.size());
    DocumentIterator* pDocIterator;
    vector<DocumentIterator*>::iterator iter = docIteratorList_.begin();
    while (iter != docIteratorList_.end())
    {
        pDocIterator = (*iter);
        if (pDocIterator)
        {
            pDocIterator->setCurrent(false);
            if(pDocIterator->next())
                pDocIteratorQueue_->insert(pDocIterator);
           else
           {
               *iter = NULL;
               delete pDocIterator;
           }
        }
        iter ++;
    }
}

void ORDocumentIterator::add(DocumentIterator* pDocIterator)
{
    if (pDocIterator->isNot())
    {
        hasNot_ = true;
        if (NULL == pNOTDocIterator_)
            pNOTDocIterator_ = new NOTDocumentIterator();
        pNOTDocIterator_->add(pDocIterator);
    }
    else
        docIteratorList_.push_back(pDocIterator);
}

bool ORDocumentIterator::next()
{'fraction_non_alphanumeric': 0.1038819026790596, 'fraction_numerical': 0.0010934937124111536, 'mean_word_length': 2.760534429599178, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5210560', 'n_tokens_mistral': 1028, 'n_tokens_neox': 1019, 'n_words': 183}