本文整理汇总了C++中TileIndex::parent方法的典型用法代码示例。如果您正苦于以下问题:C++ TileIndex::parent方法的具体用法?C++ TileIndex::parent怎么用?C++ TileIndex::parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileIndex
的用法示例。
在下文中一共展示了TileIndex::parent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move_root_upwards
void Channel::move_root_upwards(TileIndex new_root_index, TileIndex old_root_index) {
Tile old_root_tile;
Tile empty_tile;
assert(read_tile(old_root_index, old_root_tile));
TileIndex ti = old_root_index;
while (ti != new_root_index) {
write_tile(ti.sibling(), empty_tile);
write_tile(ti.parent(), old_root_tile);
ti = ti.parent();
}
}
示例2: find_successive_tile
TileIndex Channel::find_successive_tile(TileIndex root, TileIndex ti, int desired_level) const {
// Move upwards until parent has a different end time
while (1) {
if (ti.parent().is_null()) return TileIndex::null();
if (ti.parent().end_time() != ti.end_time()) break;
ti = ti.parent();
if (ti.level >= root.level) {
// No more underneath the root
return TileIndex::null();
}
}
// We are now the left child of our parent; skip to the right child
ti = ti.sibling();
return find_child_overlapping_time(ti, ti.start_time(), desired_level);
}
示例3: add_data_internal
void Channel::add_data_internal(const std::vector<DataSample<T> > &data, DataRanges *channel_ranges) {
if (!data.size()) return;
// Sanity check
if (data[0].time < 0) throw std::runtime_error("Unimplemented feature: adding data with negative time");
for (unsigned i = 0; i < data.size()-1; i++) {
if (data[i].time > data[i+1].time) throw std::runtime_error("Attempt to add data that is not sorted by ascending time");
}
// regenerate = empty set
Locker lock(*this); // Lock self and hold lock until exiting this method
std::set<TileIndex> to_regenerate;
ChannelInfo info;
bool success = read_info(info);
if (!success) {
// New channel
info.magic = ChannelInfo::MAGIC;
info.version = 0x00010000;
info.times = Range(data[0].time, data.back().time);
info.nonnegative_root_tile_index = TileIndex::nonnegative_all();
create_tile(TileIndex::nonnegative_all());
info.negative_root_tile_index = TileIndex::null();
} else {
info.times.add(Range(data[0].time, data.back().time));
// If we're not the all-tile, see if we need to move the root upwards
if (info.nonnegative_root_tile_index != TileIndex::nonnegative_all()) {
TileIndex new_nonnegative_root_tile_index = TileIndex::index_containing(info.times);
if (new_nonnegative_root_tile_index.level > info.nonnegative_root_tile_index.level) {
// Root index changed. Confirm new root is parent or more distant ancestor of old root
assert(new_nonnegative_root_tile_index.is_ancestor_of(info.nonnegative_root_tile_index));
// Trigger regeneration from old root's parent, up through new root
to_regenerate.insert(info.nonnegative_root_tile_index.parent());
move_root_upwards(new_nonnegative_root_tile_index, info.nonnegative_root_tile_index);
info.nonnegative_root_tile_index = new_nonnegative_root_tile_index;
}
}
}
unsigned i=0;
while (i < data.size()) {
TileIndex ti= find_lowest_child_overlapping_time(info.nonnegative_root_tile_index, data[i].time);
assert(!ti.is_null());
Tile tile;
assert(read_tile(ti, tile));
const DataSample<T> *begin = &data[i];
while (i < data.size() && ti.contains_time(data[i].time)) i++;
const DataSample<T> *end = &data[i];
tile.insert_samples(begin, end);
TileIndex new_root = split_tile_if_needed(ti, tile);
if (new_root != TileIndex::null()) {
assert(ti == TileIndex::nonnegative_all());
if (verbosity) log_f("Channel: %s changing root from %s to %s",
descriptor().c_str(), ti.to_string().c_str(),
new_root.to_string().c_str());
info.nonnegative_root_tile_index = new_root;
delete_tile(ti); // Delete old root
ti = new_root;
}
write_tile(ti, tile);
if (ti == info.nonnegative_root_tile_index && channel_ranges) { *channel_ranges = tile.ranges; }
if (ti != info.nonnegative_root_tile_index) to_regenerate.insert(ti.parent());
}
// Regenerate from lowest level to highest
while (!to_regenerate.empty()) {
TileIndex ti = *to_regenerate.begin();
to_regenerate.erase(to_regenerate.begin());
Tile regenerated, children[2];
assert(read_tile(ti.left_child(), children[0]));
assert(read_tile(ti.right_child(), children[1]));
create_parent_tile_from_children(ti, regenerated, children);
write_tile(ti, regenerated);
if (ti == info.nonnegative_root_tile_index && channel_ranges) { *channel_ranges = regenerated.ranges; }
if (ti != info.nonnegative_root_tile_index) to_regenerate.insert(ti.parent());
}
write_info(info);
}