forked from Mirrors/privacore-open-source-search-engine
Add constness to function
This commit is contained in:
15
RdbTree.cpp
15
RdbTree.cpp
@ -249,7 +249,7 @@ int32_t RdbTree::clear ( ) {
|
||||
|
||||
// . used by cache
|
||||
// . wrapper for getNode()
|
||||
int32_t RdbTree::getNode(collnum_t collnum, const char *key) {
|
||||
int32_t RdbTree::getNode(collnum_t collnum, const char *key) const {
|
||||
int32_t i = m_headNode;
|
||||
|
||||
// get the node (about 4 cycles per loop, 80cycles for 1 million items)
|
||||
@ -321,19 +321,19 @@ int32_t RdbTree::getNextNode(collnum_t collnum, const char *key) const {
|
||||
return getNextNode ( parent );
|
||||
}
|
||||
|
||||
int32_t RdbTree::getFirstNode ( ) {
|
||||
int32_t RdbTree::getFirstNode() const {
|
||||
const char *k = KEYMIN();
|
||||
return getNextNode ( 0 , k );
|
||||
}
|
||||
|
||||
int32_t RdbTree::getLastNode ( ) {
|
||||
int32_t RdbTree::getLastNode() const {
|
||||
const char *k = KEYMAX();
|
||||
return getPrevNode ( (collnum_t)0x7fff , k );
|
||||
}
|
||||
|
||||
// . get the node whose key is <= "key"
|
||||
// . returns -1 if none
|
||||
int32_t RdbTree::getPrevNode ( collnum_t collnum, const char *key ) {
|
||||
int32_t RdbTree::getPrevNode(collnum_t collnum, const char *key) const {
|
||||
// return -1 if no non-empty nodes in the tree
|
||||
if ( m_headNode < 0 ) return -1;
|
||||
// get the node (about 4 cycles per loop, 80cycles for 1 million items)
|
||||
@ -356,8 +356,9 @@ int32_t RdbTree::getPrevNode ( collnum_t collnum, const char *key ) {
|
||||
return getPrevNode ( parent );
|
||||
}
|
||||
|
||||
char *RdbTree::getData ( collnum_t collnum, const char *key ) {
|
||||
int32_t n = getNode ( collnum , key ); if ( n < 0 ) return NULL;
|
||||
const char *RdbTree::getData(collnum_t collnum, const char *key) const {
|
||||
int32_t n = getNode(collnum, key);
|
||||
if (n < 0) return NULL;
|
||||
return m_data[n];
|
||||
};
|
||||
|
||||
@ -395,7 +396,7 @@ int32_t RdbTree::getNextNode(int32_t i) const {
|
||||
}
|
||||
|
||||
// . "i" is the next node number
|
||||
int32_t RdbTree::getPrevNode ( int32_t i ) {
|
||||
int32_t RdbTree::getPrevNode(int32_t i) const {
|
||||
// cruise the kids if we have a left one
|
||||
if ( m_left[i] >= 0 ) {
|
||||
// go to the left kid
|
||||
|
21
RdbTree.h
21
RdbTree.h
@ -100,16 +100,10 @@ public:
|
||||
}
|
||||
|
||||
int32_t addNode(collnum_t collnum, const char *key, char *data, int32_t dataSize);
|
||||
int32_t addNode(collnum_t collnum, const char *key) {
|
||||
return addNode(collnum, key, NULL, 0);
|
||||
}
|
||||
|
||||
|
||||
// . returns -1 if not found
|
||||
// . otherwise return the node #
|
||||
int32_t getNode ( collnum_t collnum, const char *key );
|
||||
|
||||
// . get the node's data directly
|
||||
char *getData ( collnum_t collnum, const char *key );
|
||||
int32_t getNode ( collnum_t collnum, const char *key ) const;
|
||||
|
||||
// . get the node whose key is >= key
|
||||
// . much much slower than getNextNode() below
|
||||
@ -121,14 +115,14 @@ public:
|
||||
// . returns -1 on end
|
||||
int32_t getNextNode(int32_t node) const;
|
||||
|
||||
int32_t getFirstNode ( );
|
||||
int32_t getLastNode ( );
|
||||
int32_t getFirstNode() const;
|
||||
int32_t getLastNode() const;
|
||||
|
||||
// . get the node whose key is <= "key"
|
||||
int32_t getPrevNode(collnum_t collnum, const char *key);
|
||||
int32_t getPrevNode(collnum_t collnum, const char *key) const;
|
||||
|
||||
// . get the prev node # whose key is <= to key of node #i
|
||||
int32_t getPrevNode ( int32_t i ) ;
|
||||
int32_t getPrevNode(int32_t i) const;
|
||||
|
||||
// . returns true iff was found and deleted
|
||||
// . returns false iff not found
|
||||
@ -155,8 +149,7 @@ public:
|
||||
|
||||
bool isLoading() const { return m_isLoading; }
|
||||
|
||||
// since our arrays aren't public
|
||||
char *getData(int32_t node) { return m_data[node]; }
|
||||
const char *getData(collnum_t collnum, const char *key) const;
|
||||
const char *getData(int32_t node) const { return m_data[node]; }
|
||||
void setData(int32_t node, char *data) {
|
||||
m_data[node] = data;
|
||||
|
Reference in New Issue
Block a user