From 9cf00098f4628fb9797bb14963686384d406883b Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 5 Dec 2011 14:19:20 +0800 Subject: add const modifiers --- src/storage/ngram.cpp | 9 +++++---- src/storage/ngram.h | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/storage/ngram.cpp b/src/storage/ngram.cpp index 66cdc56..86c12fe 100644 --- a/src/storage/ngram.cpp +++ b/src/storage/ngram.cpp @@ -83,7 +83,8 @@ static bool token_less_than(const SingleGramItem & lhs,const SingleGramItem & rh return lhs.m_token < rhs.m_token; } -bool SingleGram::retrieve_all(/* out */ BigramPhraseWithCountArray array){ +bool SingleGram::retrieve_all(/* out */ BigramPhraseWithCountArray array) + const { const SingleGramItem * begin = (const SingleGramItem *) ((const char *)(m_chunk.begin()) + sizeof(guint32)); const SingleGramItem * end = (const SingleGramItem *) m_chunk.end(); @@ -102,8 +103,8 @@ bool SingleGram::retrieve_all(/* out */ BigramPhraseWithCountArray array){ return true; } -bool SingleGram::search(/* in */ PhraseIndexRange * range, - /* out */ BigramPhraseArray array){ +bool SingleGram::search(/* in */ PhraseIndexRange * range, + /* out */ BigramPhraseArray array) const { const SingleGramItem * begin = (const SingleGramItem *) ((const char *)(m_chunk.begin()) + sizeof(guint32)); const SingleGramItem * end = (const SingleGramItem *)m_chunk.end(); @@ -181,7 +182,7 @@ bool SingleGram::remove_freq( /* in */ phrase_token_t token, } bool SingleGram::get_freq(/* in */ phrase_token_t token, - /* out */ guint32 & freq){ + /* out */ guint32 & freq) const { freq = 0; const SingleGramItem * begin = (const SingleGramItem *) ((const char *)(m_chunk.begin()) + sizeof(guint32)); diff --git a/src/storage/ngram.h b/src/storage/ngram.h index 8863392..73e422a 100644 --- a/src/storage/ngram.h +++ b/src/storage/ngram.h @@ -52,12 +52,12 @@ public: /* Null Constructor */ SingleGram(); /* retrieve all items */ - bool retrieve_all(/* out */ BigramPhraseWithCountArray array); + bool retrieve_all(/* out */ BigramPhraseWithCountArray array) const; /* search method */ /* the array result contains many items */ - bool search(/* in */ PhraseIndexRange * range, - /* out */ BigramPhraseArray array); + bool search(/* in */ PhraseIndexRange * range, + /* out */ BigramPhraseArray array) const; /* insert_freq method */ @@ -72,7 +72,7 @@ public: /* get_freq method */ bool get_freq(/* in */ phrase_token_t token, - /* out */ guint32 & freq); + /* out */ guint32 & freq) const; /* set_freq method */ -- cgit