summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2013-04-18 11:16:14 +0800
committerPeng Wu <alexepico@gmail.com>2013-04-18 11:16:14 +0800
commit0ee1b6a1b63ae2d55684bd982a95a6a9389f12d2 (patch)
treecf3b406791589c4f89b453aa457b786801af7852 /src
parentbd771b0c51f35c6ab6377719ab654370782ef1c9 (diff)
downloadlibpinyin-0ee1b6a1b63ae2d55684bd982a95a6a9389f12d2.tar.gz
libpinyin-0ee1b6a1b63ae2d55684bd982a95a6a9389f12d2.tar.xz
libpinyin-0ee1b6a1b63ae2d55684bd982a95a6a9389f12d2.zip
add const modifiers for phrase table
Diffstat (limited to 'src')
-rw-r--r--src/storage/facade_phrase_table2.h6
-rw-r--r--src/storage/phrase_large_table2.cpp32
-rw-r--r--src/storage/phrase_large_table2.h12
3 files changed, 25 insertions, 25 deletions
diff --git a/src/storage/facade_phrase_table2.h b/src/storage/facade_phrase_table2.h
index 4167ada..3ef1c37 100644
--- a/src/storage/facade_phrase_table2.h
+++ b/src/storage/facade_phrase_table2.h
@@ -120,7 +120,7 @@ public:
* Search the phrase tokens according to the ucs4 characters.
*
*/
- int search(int phrase_length, /* in */ ucs4_t phrase[],
+ int search(int phrase_length, /* in */ const ucs4_t phrase[],
/* out */ PhraseTokens tokens) const {
/* clear tokens. */
for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
@@ -151,7 +151,7 @@ public:
* Add the phrase token to the user phrase table.
*
*/
- int add_index(int phrase_length, /* in */ ucs4_t phrase[],
+ int add_index(int phrase_length, /* in */ const ucs4_t phrase[],
/* in */ phrase_token_t token) {
if (NULL == m_user_phrase_table)
return ERROR_NO_USER_TABLE;
@@ -170,7 +170,7 @@ public:
* Remove the phrase token from the user phrase table.
*
*/
- int remove_index(int phrase_length, /* in */ ucs4_t phrase[],
+ int remove_index(int phrase_length, /* in */ const ucs4_t phrase[],
/* in */ phrase_token_t token) {
if (NULL == m_user_phrase_table)
return ERROR_NO_USER_TABLE;
diff --git a/src/storage/phrase_large_table2.cpp b/src/storage/phrase_large_table2.cpp
index 11b5fef..fadbbe3 100644
--- a/src/storage/phrase_large_table2.cpp
+++ b/src/storage/phrase_large_table2.cpp
@@ -40,13 +40,13 @@ public:
bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end);
/* search method */
- int search(int phrase_length, /* in */ ucs4_t phrase[],
+ int search(int phrase_length, /* in */ const ucs4_t phrase[],
/* out */ PhraseTokens tokens) const;
/* add_index/remove_index method */
- int add_index(int phrase_length, /* in */ ucs4_t phrase[],
+ int add_index(int phrase_length, /* in */ const ucs4_t phrase[],
/* in */ phrase_token_t token);
- int remove_index(int phrase_length, /* in */ ucs4_t phrase[],
+ int remove_index(int phrase_length, /* in */ const ucs4_t phrase[],
/* in */ phrase_token_t token);
/* get length method */
@@ -62,7 +62,7 @@ struct PhraseIndexItem2{
phrase_token_t m_token;
ucs4_t m_phrase[phrase_length];
public:
- PhraseIndexItem2<phrase_length>(ucs4_t phrase[], phrase_token_t token){
+ PhraseIndexItem2<phrase_length>(const ucs4_t phrase[], phrase_token_t token){
memmove(m_phrase, phrase, sizeof(ucs4_t) * phrase_length);
m_token = token;
}
@@ -81,11 +81,11 @@ public:
bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end);
/* search method */
- int search(/* in */ ucs4_t phrase[], /* out */ PhraseTokens tokens) const;
+ int search(/* in */ const ucs4_t phrase[], /* out */ PhraseTokens tokens) const;
/* add_index/remove_index method */
- int add_index(/* in */ ucs4_t phrase[], /* in */ phrase_token_t token);
- int remove_index(/* in */ ucs4_t phrase[], /* in */ phrase_token_t token);
+ int add_index(/* in */ const ucs4_t phrase[], /* in */ phrase_token_t token);
+ int remove_index(/* in */ const ucs4_t phrase[], /* in */ phrase_token_t token);
/* get length method */
int get_length() const;
@@ -133,7 +133,7 @@ void PhraseBitmapIndexLevel2::reset(){
/* search method */
int PhraseBitmapIndexLevel2::search(int phrase_length,
- /* in */ ucs4_t phrase[],
+ /* in */ const ucs4_t phrase[],
/* out */ PhraseTokens tokens) const {
assert(phrase_length > 0);
@@ -193,7 +193,7 @@ PhraseLengthIndexLevel2::~PhraseLengthIndexLevel2(){
}
int PhraseLengthIndexLevel2::search(int phrase_length,
- /* in */ ucs4_t phrase[],
+ /* in */ const ucs4_t phrase[],
/* out */ PhraseTokens tokens) const {
int result = SEARCH_NONE;
if(m_phrase_array_indexes->len < phrase_length)
@@ -236,7 +236,7 @@ int PhraseLengthIndexLevel2::search(int phrase_length,
template<size_t phrase_length>
int PhraseArrayIndexLevel2<phrase_length>::search
-(/* in */ ucs4_t phrase[], /* out */ PhraseTokens tokens) const {
+(/* in */ const ucs4_t phrase[], /* out */ PhraseTokens tokens) const {
int result = SEARCH_NONE;
IndexItem * chunk_begin = NULL, * chunk_end = NULL;
@@ -278,7 +278,7 @@ int PhraseArrayIndexLevel2<phrase_length>::search
/* add/remove index method */
int PhraseBitmapIndexLevel2::add_index(int phrase_length,
- /* in */ ucs4_t phrase[],
+ /* in */ const ucs4_t phrase[],
/* in */ phrase_token_t token){
guint8 first_key = (phrase[0] & 0xFF00) >> 8;
@@ -292,7 +292,7 @@ int PhraseBitmapIndexLevel2::add_index(int phrase_length,
}
int PhraseBitmapIndexLevel2::remove_index(int phrase_length,
- /* in */ ucs4_t phrase[],
+ /* in */ const ucs4_t phrase[],
/* in */ phrase_token_t token){
guint8 first_key = (phrase[0] & 0xFF00) >> 8;
@@ -314,7 +314,7 @@ int PhraseBitmapIndexLevel2::remove_index(int phrase_length,
}
int PhraseLengthIndexLevel2::add_index(int phrase_length,
- /* in */ ucs4_t phrase[],
+ /* in */ const ucs4_t phrase[],
/* in */ phrase_token_t token) {
if (phrase_length >= MAX_PHRASE_LENGTH)
return ERROR_PHRASE_TOO_LONG;
@@ -356,7 +356,7 @@ int PhraseLengthIndexLevel2::add_index(int phrase_length,
}
int PhraseLengthIndexLevel2::remove_index(int phrase_length,
- /* in */ ucs4_t phrase[],
+ /* in */ const ucs4_t phrase[],
/* in */ phrase_token_t token) {
if (phrase_length >= MAX_PHRASE_LENGTH)
return ERROR_PHRASE_TOO_LONG;
@@ -410,7 +410,7 @@ int PhraseLengthIndexLevel2::remove_index(int phrase_length,
template<size_t phrase_length>
int PhraseArrayIndexLevel2<phrase_length>::add_index
-(/* in */ ucs4_t phrase[], /* in */ phrase_token_t token){
+(/* in */ const ucs4_t phrase[], /* in */ phrase_token_t token){
IndexItem * begin, * end;
IndexItem add_elem(phrase, token);
@@ -437,7 +437,7 @@ int PhraseArrayIndexLevel2<phrase_length>::add_index
template<size_t phrase_length>
int PhraseArrayIndexLevel2<phrase_length>::remove_index
-(/* in */ ucs4_t phrase[], /* in */ phrase_token_t token) {
+(/* in */ const ucs4_t phrase[], /* in */ phrase_token_t token) {
IndexItem * begin, * end;
IndexItem remove_elem(phrase, token);
diff --git a/src/storage/phrase_large_table2.h b/src/storage/phrase_large_table2.h
index d92fa0e..45182d9 100644
--- a/src/storage/phrase_large_table2.h
+++ b/src/storage/phrase_large_table2.h
@@ -48,13 +48,13 @@ public:
bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end);
/* search method */
- int search(int phrase_length, /* in */ ucs4_t phrase[],
+ int search(int phrase_length, /* in */ const ucs4_t phrase[],
/* out */ PhraseTokens tokens) const;
/* add_index/remove_index method */
- int add_index(int phrase_length, /* in */ ucs4_t phrase[], /* in */ phrase_token_t token);
+ int add_index(int phrase_length, /* in */ const ucs4_t phrase[], /* in */ phrase_token_t token);
- int remove_index(int phrase_length, /* in */ ucs4_t phrase[], /* in */ phrase_token_t token);
+ int remove_index(int phrase_length, /* in */ const ucs4_t phrase[], /* in */ phrase_token_t token);
/* mask out method */
bool mask_out(phrase_token_t mask, phrase_token_t value);
@@ -96,17 +96,17 @@ public:
bool load_text(FILE * file);
/* search method */
- int search(int phrase_length, /* in */ ucs4_t phrase[],
+ int search(int phrase_length, /* in */ const ucs4_t phrase[],
/* out */ PhraseTokens tokens) const {
return m_bitmap_table.search(phrase_length, phrase, tokens);
}
/* add_index/remove_index method */
- int add_index(int phrase_length, /* in */ ucs4_t phrase[], /* in */ phrase_token_t token) {
+ int add_index(int phrase_length, /* in */ const ucs4_t phrase[], /* in */ phrase_token_t token) {
return m_bitmap_table.add_index(phrase_length, phrase, token);
}
- int remove_index(int phrase_length, /* in */ ucs4_t phrase[], /* in */ phrase_token_t token) {
+ int remove_index(int phrase_length, /* in */ const ucs4_t phrase[], /* in */ phrase_token_t token) {
return m_bitmap_table.remove_index(phrase_length, phrase, token);
}