void set_is_offset(bool x) { if (x) { GRN_DAT_DEBUG_THROW_IF(is_offset()); value_ |= IS_OFFSET_FLAG; } else { GRN_DAT_DEBUG_THROW_IF(!is_offset()); value_ &= ~IS_OFFSET_FLAG; } }
// To reject a transition to an incomplete node, set_is_phantom() invalidates // its label and links when it becomes non-phantom. void set_is_phantom(bool x) { if (x) { GRN_DAT_DEBUG_THROW_IF(is_phantom()); value_ |= IS_PHANTOM_FLAG; } else { GRN_DAT_DEBUG_THROW_IF(!is_phantom()); value_ = (value_ & IS_OFFSET_FLAG) | (INVALID_LABEL << CHILD_SHIFT) | (INVALID_LABEL << SIBLING_SHIFT) | INVALID_LABEL; } }
// This function returns an integer as follows: // - a negative value if *this < rhs, // - zero if *this == rhs, // - a positive value if *this > rhs, // but if the offset is too large, the result is undefined. int compare(const String &rhs, UInt32 offset = 0) const { GRN_DAT_DEBUG_THROW_IF(offset > length()); GRN_DAT_DEBUG_THROW_IF(offset > rhs.length()); for (UInt32 i = offset; i < length(); ++i) { if (i >= rhs.length()) { return 1; } else if ((*this)[i] != rhs[i]) { return (*this)[i] - rhs[i]; } } return (length() == rhs.length()) ? 0 : -1; }
UInt32 ith_leader(UInt32 i) const { GRN_DAT_DEBUG_THROW_IF(i > MAX_BLOCK_LEVEL); return leaders_[i]; }
Array(void *ptr, UInt32 size) : ptr_(static_cast<T *>(ptr)), size_(size) { GRN_DAT_DEBUG_THROW_IF((ptr == NULL) && (size != 0)); }
void set_file_size(UInt64 x) { GRN_DAT_DEBUG_THROW_IF(x > MAX_FILE_SIZE); file_size_ = x; }
const Block &ith_block(UInt32 i) const { GRN_DAT_DEBUG_THROW_IF(i >= num_blocks()); return blocks_[i]; }
void set_offset(UInt32 x) { GRN_DAT_DEBUG_THROW_IF((x & IS_LINKER_FLAG) != 0); GRN_DAT_DEBUG_THROW_IF(x > MAX_OFFSET); value_ = x; }
const UInt8 &operator[](UInt32 i) const { GRN_DAT_DEBUG_THROW_IF(i >= length_); return ptr_[i]; }
void set_num_zombies(UInt32 x) { GRN_DAT_DEBUG_THROW_IF(x > max_num_nodes()); num_zombies_ = x; }
UInt32 offset() const { GRN_DAT_DEBUG_THROW_IF(is_linker()); return value_; }
void set_max_num_keys(UInt32 x) { GRN_DAT_DEBUG_THROW_IF(x > MAX_NUM_KEYS); max_num_keys_ = x; }
void set_num_phantoms(UInt32 x) { GRN_DAT_DEBUG_THROW_IF(x > max_num_nodes()); num_phantoms_ = x; }
void set_max_key_id(UInt32 x) { GRN_DAT_DEBUG_THROW_IF(x > MAX_KEY_ID); max_key_id_ = x; }
void set_next_key_id(UInt32 x) { GRN_DAT_DEBUG_THROW_IF((x - 1) > MAX_KEY_ID); next_key_id_ = x; }
void set_total_key_length(UInt32 x) { GRN_DAT_DEBUG_THROW_IF(x > MAX_TOTAL_KEY_LENGTH); total_key_length_ = x; }
T &operator[](UInt32 i) { GRN_DAT_DEBUG_THROW_IF(i >= size_); return ptr_[i]; }
void set_num_blocks(UInt32 x) { GRN_DAT_DEBUG_THROW_IF(x > max_num_blocks()); num_blocks_ = x; }
void assign(void *ptr, UInt32 size) { GRN_DAT_DEBUG_THROW_IF((ptr == NULL) && (size != 0)); ptr_ = static_cast<T *>(ptr); size_ = size; }
void set_max_num_blocks(UInt32 x) { GRN_DAT_DEBUG_THROW_IF(x > MAX_NUM_BLOCKS); max_num_blocks_ = x; }
UInt32 key_pos() const { GRN_DAT_DEBUG_THROW_IF(!is_linker()); return value_ & ~IS_LINKER_FLAG; }
T &operator[](UInt32 i) { GRN_DAT_DEBUG_THROW_IF(i >= size()); return buf_[i]; }
void set_key_pos(UInt32 x) { GRN_DAT_DEBUG_THROW_IF((x & IS_LINKER_FLAG) != 0); GRN_DAT_DEBUG_THROW_IF(x > MAX_OFFSET); value_ = IS_LINKER_FLAG | x; }
T &back() { GRN_DAT_DEBUG_THROW_IF(empty()); return buf_[size() - 1]; }
void set_next_key_pos(UInt32 x) { GRN_DAT_DEBUG_THROW_IF(x > key_buf_size()); next_key_pos_ = x; }
const Entry &ith_entry(UInt32 i) const { GRN_DAT_DEBUG_THROW_IF(i < min_key_id()); GRN_DAT_DEBUG_THROW_IF(i > max_key_id()); return entries_[i]; }
T &front() { GRN_DAT_DEBUG_THROW_IF(empty()); return buf_[0]; }
void set_key_buf_size(UInt32 x) { GRN_DAT_DEBUG_THROW_IF(x > MAX_KEY_BUF_SIZE); key_buf_size_ = x; }
void pop_back() { GRN_DAT_DEBUG_THROW_IF(empty()); back().~T(); --size_; }
void set_ith_leader(UInt32 i, UInt32 x) { GRN_DAT_DEBUG_THROW_IF(i > MAX_BLOCK_LEVEL); GRN_DAT_DEBUG_THROW_IF((x != INVALID_LEADER) && (x >= num_blocks())); leaders_[i] = x; }