From deb87782053cae13832db444977b396b30913f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <Pawel.Kedzia@pwr.wroc.pl> Date: Tue, 3 Jan 2012 11:50:02 +0100 Subject: [PATCH] fixed next_document --- libcorpus2_whole/corpus.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/libcorpus2_whole/corpus.h b/libcorpus2_whole/corpus.h index d00a326..85c5caf 100644 --- a/libcorpus2_whole/corpus.h +++ b/libcorpus2_whole/corpus.h @@ -50,17 +50,20 @@ public: /// Next document in corpus boost::shared_ptr<Document> next_document() { + static boost::shared_ptr<Document> _empty_doc_ptr; if (!this->set_) { if (this->documents_.size() == 0) { - boost::shared_ptr<Document> tmp; - return tmp; - } - else { - this->set_ = true; - this->current_document_ = documents_.begin(); + return _empty_doc_ptr; } + + this->set_ = true; + this->current_document_ = documents_.begin(); } else { + if (current_document_ == documents_.end()) { + return _empty_doc_ptr; + } + current_document_++; } -- GitLab