From 455f2a2c2bbcaf59e243f46c4c79aa13dfb6c1eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20K=C4=99dzia?= <Pawel.Kedzia@pwr.wroc.pl>
Date: Thu, 29 Dec 2011 13:44:21 +0100
Subject: [PATCH] fixed next_document in Cropus

---
 libcorpus2_whole/corpus.cpp |  2 +-
 libcorpus2_whole/corpus.h   | 14 ++++++++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/libcorpus2_whole/corpus.cpp b/libcorpus2_whole/corpus.cpp
index 06df2f9..00fb0ff 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 c37c60e..3f1a55e 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_;
 
-- 
GitLab