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(); } }
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); }