本文整理汇总了C++中ranges::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ranges::empty方法的具体用法?C++ ranges::empty怎么用?C++ ranges::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ranges
的用法示例。
在下文中一共展示了ranges::empty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextrange
//intersect(currentHint,possibleRanges[j])
//modifies rangelist
range nextrange(ranges &rangelist, range &myrange)
{
if(rangelist.empty())
{
range retRange = myrange;
myrange.start = myrange.end+1;
return retRange;
}
else
{
if(myrange.start > rangelist[0].end)
{
//rangelist[0] is the next range for sure.
range retRange = rangelist[0];
rangelist.erase(rangelist.begin());
return retRange;
}
else if(myrange.start == rangelist[0].end)
{
if(rangelist[0].start == rangelist[0].end )
{
rangelist[0].score++;
range retRange = rangelist[0];
rangelist.erase(rangelist.begin());
myrange.start++;
return retRange;
}
else
{
range retRange = rangelist[0];
retRange.end--;
rangelist[0].start = rangelist[0].end;
rangelist[0].score++;
myrange.start++;
return retRange;
}
}
else if(myrange.start >rangelist[0].start)
{
//we have an intersection here. rangelist[0] <=> myrange.start-1
//update rangelist first element accordingly
range retRange = range(rangelist[0].start,myrange.start-1,rangelist[0].score);
rangelist[0].start = myrange.start;
return retRange;
}
else if(myrange.start == rangelist[0].start)
{
if(myrange.end < rangelist[0].end)
{
// myrange.start to myrange.end is the next range.
// We add 1 to score of rangelist[0] score
range retRange = range(myrange.start,myrange.end,rangelist[0].score+1);
rangelist[0].start = myrange.end+1;
myrange.start = myrange.end+1;
return retRange;
}
else
{
//takes care of myrange.end = rl[0].end also
// rangelist[0] with inc score is the nextrange. Remove it from the list.
// update myrange accordingly
range retRange = range(rangelist[0].start,rangelist[0].end,rangelist[0].score+1);
myrange.start = rangelist[0].end+1;
rangelist.erase(rangelist.begin());
return retRange;
}
}
else
{
//myrange.start < rangelist[0].start
int end = MIN(myrange.end,rangelist[0].start-1);
range retRange = range(myrange.start,end,1);
myrange.start = end+1;
return retRange;
}
}
}