本文整理汇总了C++中ColPartition::right_key方法的典型用法代码示例。如果您正苦于以下问题:C++ ColPartition::right_key方法的具体用法?C++ ColPartition::right_key怎么用?C++ ColPartition::right_key使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ColPartition
的用法示例。
在下文中一共展示了ColPartition::right_key方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AccumulateColumnWidthsAndGaps
// Accumulate the widths and gaps into the given variables.
void ColPartitionSet::AccumulateColumnWidthsAndGaps(int* total_width,
int* width_samples,
int* total_gap,
int* gap_samples) {
ColPartition_IT it(&parts_);
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
ColPartition* part = it.data();
*total_width += part->ColumnWidth();
++*width_samples;
if (!it.at_last()) {
ColPartition* next_part = it.data_relative(1);
int gap = part->KeyWidth(part->right_key(), next_part->left_key());
*total_gap += gap;
++*gap_samples;
}
}
}
示例2: LegalColumnCandidate
// Return true if this ColPartitionSet makes a legal column candidate by
// having legal individual partitions and non-overlapping adjacent pairs.
bool ColPartitionSet::LegalColumnCandidate() {
ColPartition_IT it(&parts_);
if (it.empty())
return false;
bool any_text_parts = false;
for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
ColPartition* part = it.data();
if (BLOBNBOX::IsTextType(part->blob_type())) {
if (!part->IsLegal())
return false; // Individual partition is illegal.
any_text_parts = true;
}
if (!it.at_last()) {
ColPartition* next_part = it.data_relative(1);
if (next_part->left_key() < part->right_key()) {
return false;
}
}
}
return any_text_parts;
}
示例3: ImproveColumnCandidate
// Attempt to improve this by adding partitions or expanding partitions.
void ColPartitionSet::ImproveColumnCandidate(WidthCallback* cb,
PartSetVector* src_sets) {
int set_size = src_sets->size();
// Iterate over the provided column sets, as each one may have something
// to improve this.
for (int i = 0; i < set_size; ++i) {
ColPartitionSet* column_set = src_sets->get(i);
if (column_set == NULL)
continue;
// Iterate over the parts in this and column_set, adding bigger or
// new parts in column_set to this.
ColPartition_IT part_it(&parts_);
ASSERT_HOST(!part_it.empty());
int prev_right = MIN_INT32;
part_it.mark_cycle_pt();
ColPartition_IT col_it(&column_set->parts_);
for (col_it.mark_cycle_pt(); !col_it.cycled_list(); col_it.forward()) {
ColPartition* col_part = col_it.data();
if (col_part->blob_type() < BRT_UNKNOWN)
continue; // Ignore image partitions.
int col_left = col_part->left_key();
int col_right = col_part->right_key();
// Sync-up part_it (in this) so it matches the col_part in column_set.
ColPartition* part = part_it.data();
while (!part_it.at_last() && part->right_key() < col_left) {
prev_right = part->right_key();
part_it.forward();
part = part_it.data();
}
int part_left = part->left_key();
int part_right = part->right_key();
if (part_right < col_left || col_right < part_left) {
// There is no overlap so this is a new partition.
AddPartition(col_part->ShallowCopy(), &part_it);
continue;
}
// Check the edges of col_part to see if they can improve part.
bool part_width_ok = cb->Run(part->KeyWidth(part_left, part_right));
if (col_left < part_left && col_left > prev_right) {
// The left edge of the column is better and it doesn't overlap,
// so we can potentially expand it.
int col_box_left = col_part->BoxLeftKey();
bool tab_width_ok = cb->Run(part->KeyWidth(col_left, part_right));
bool box_width_ok = cb->Run(part->KeyWidth(col_box_left, part_right));
if (tab_width_ok || (!part_width_ok )) {
// The tab is leaving the good column metric at least as good as
// it was before, so use the tab.
part->CopyLeftTab(*col_part, false);
part->SetColumnGoodness(cb);
} else if (col_box_left < part_left &&
(box_width_ok || !part_width_ok)) {
// The box is leaving the good column metric at least as good as
// it was before, so use the box.
part->CopyLeftTab(*col_part, true);
part->SetColumnGoodness(cb);
}
part_left = part->left_key();
}
if (col_right > part_right &&
(part_it.at_last() ||
part_it.data_relative(1)->left_key() > col_right)) {
// The right edge is better, so we can possibly expand it.
int col_box_right = col_part->BoxRightKey();
bool tab_width_ok = cb->Run(part->KeyWidth(part_left, col_right));
bool box_width_ok = cb->Run(part->KeyWidth(part_left, col_box_right));
if (tab_width_ok || (!part_width_ok )) {
// The tab is leaving the good column metric at least as good as
// it was before, so use the tab.
part->CopyRightTab(*col_part, false);
part->SetColumnGoodness(cb);
} else if (col_box_right > part_right &&
(box_width_ok || !part_width_ok)) {
// The box is leaving the good column metric at least as good as
// it was before, so use the box.
part->CopyRightTab(*col_part, true);
part->SetColumnGoodness(cb);
}
}
}
}
ComputeCoverage();
}