diff --git a/libcorpus2_whole/corpus.cpp b/libcorpus2_whole/corpus.cpp index 06df2f9a0f768e609747b1edc2b0d3dd0f7826c6..00fb0ffe2e979a485945ed2ea23eb04d8da3f715 100644 --- a/libcorpus2_whole/corpus.cpp +++ b/libcorpus2_whole/corpus.cpp @@ -21,7 +21,7 @@ namespace whole{ Corpus::Corpus(const std::string name) : name_(name), documents_() { - this->current_document_ = documents_.begin(); + set_ = false; } } // whole ns diff --git a/libcorpus2_whole/corpus.h b/libcorpus2_whole/corpus.h index c37c60ec65647ed06bb3bad69af8e2dd9e8ba849..3f1a55e8d12166432f1d03ee2144fd9cb4a272b6 100644 --- a/libcorpus2_whole/corpus.h +++ b/libcorpus2_whole/corpus.h @@ -49,12 +49,22 @@ public: } /// Next document in corpus - /// @todo I don't know if it'll be working... It should be tested! boost::shared_ptr<Document> next_document() { - return *(current_document_++); + if (!this->set_) { + this->set_ = true; + this->current_document_ = documents_.begin(); + + } + else { + current_document_++; + } + + return *current_document_; } private: + bool set_; + /// Corpus name const std::string name_;