Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kpu/kenlm.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2020-02-25 19:02:10 +0300
committerKenneth Heafield <github@kheafield.com>2020-02-25 19:02:10 +0300
commit2fc4130cd79949df2545f3ab48798b8634a00a79 (patch)
tree36f5899f74afcca804ae697dfdeda7d5edfb7f89
parent0929c4d225a3ab85fef68d9f44200838d6561992 (diff)
Add peek function for consistency with preprocess
-rw-r--r--util/file_piece.hh10
1 files changed, 8 insertions, 2 deletions
diff --git a/util/file_piece.hh b/util/file_piece.hh
index 042a78e..fc60dd1 100644
--- a/util/file_piece.hh
+++ b/util/file_piece.hh
@@ -81,12 +81,18 @@ class FilePiece {
return LineIterator();
}
- char get() {
+ char peek() {
if (position_ == position_end_) {
Shift();
if (at_end_) throw EndOfFileException();
}
- return *(position_++);
+ return *position_;
+ }
+
+ char get() {
+ char ret = peek();
+ ++position_;
+ return ret;
}
// Leaves the delimiter, if any, to be returned by get(). Delimiters defined by isspace().