mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
An helper function we need.
This commit is contained in:
@@ -52,6 +52,20 @@ int RangeSet::getPrev(int v) const
|
||||
return RangeSetAbsent;
|
||||
}
|
||||
|
||||
int RangeSet::prevMissing(int v) const
|
||||
{ // largest number not in the set that is less than the given number
|
||||
for (const_reverse_iterator it = rbegin(); it != rend(); ++it)
|
||||
{
|
||||
if (lower(it) <= v)
|
||||
{
|
||||
if (upper(it) < v)
|
||||
return upper(it) + 1;
|
||||
return lower(it) - 1;
|
||||
}
|
||||
}
|
||||
return RangeSetAbsent;
|
||||
}
|
||||
|
||||
void RangeSet::setValue(int v)
|
||||
{
|
||||
setRange(v, v);
|
||||
|
||||
@@ -33,11 +33,14 @@ public:
|
||||
int getLast() const;
|
||||
int getPrev(int) const;
|
||||
|
||||
int prevMissing(int) const; // largest number not in the set that is less than the given number
|
||||
|
||||
void setValue(int);
|
||||
void setRange(int, int);
|
||||
void clearValue(int);
|
||||
void clearRange(int, int);
|
||||
|
||||
|
||||
void clear() { mRanges.clear(); }
|
||||
|
||||
// iterator stuff
|
||||
|
||||
Reference in New Issue
Block a user