47 flags = fix_flags(flags);
49 new_cursor.init(str, min_length);
50 new_cursor.swap(
this);
55 new_cursor.swap(
this);
63 return trie_->
get_key(buf_[cur_++]);
65 return trie_->
get_key(buf_[--cur_]);
89 if (cursor_order == 0) {
99 void PrefixCursor::init(
const String &str,
UInt32 min_length) {
100 if ((limit_ == 0) || (offset_ > (str.length() - min_length))) {
106 for (i = 0; i < str.length(); ++
i) {
108 if (base.is_linker()) {
109 const Key &key = trie_->
get_key(base.key_pos());
110 if ((key.length() >= min_length) && (key.length() <= str.length()) &&
111 (str.substr(0, key.length()).compare(key.str(),
i) == 0) &&
112 ((key.length() < str.length()) ||
119 if ((i >= min_length) &&
121 const Base linker_base =
123 if (linker_base.is_linker()) {
128 node_id = base.offset() ^ str[
i];
134 if ((i == str.length()) &&
137 if (base.is_linker()) {
138 const Key &key = trie_->
get_key(base.key_pos());
139 if ((key.length() >= min_length) && (key.length() <= str.length())) {
143 const Base linker_base =
145 if (linker_base.is_linker()) {
151 if (buf_.
size() <= offset_) {
157 end_ = (limit_ < (buf_.
size() - cur_)) ? (cur_ + limit_) : buf_.
size();
159 cur_ = buf_.
size() - offset_;
160 end_ = (limit_ < cur_) ? (cur_ - limit_) : 0;
164 void PrefixCursor::swap(PrefixCursor *cursor) {
165 std::swap(trie_, cursor->trie_);
166 std::swap(offset_, cursor->offset_);
167 std::swap(limit_, cursor->limit_);
168 std::swap(flags_, cursor->flags_);
169 buf_.
swap(&cursor->buf_);
170 std::swap(cur_, cursor->cur_);
171 std::swap(end_, cursor->end_);