ROSE 0.11.145.147
|
Range of values delimited by endpoints.
This class represents a range of contiguous values by specifying the lower and upper end points, both of which are included in the range. Alternatively, a range may be empty; the default constructor creates empty ranges. The value type, T
, is intended to be an unsigned integer type. Signed integers may be used, but the caller should be prepared to handle negative sizes due to overflow (see size). Non-integer types are not recommended since some methods (e.g., size) assume that n and n+1 are adjacent values, which is not the case for floating point.
Values of this type are immutable except for the assignment operator; operations like intersection return a new object rather than modifying an existing object.
Definition at line 31 of file Interval.h.
#include <Sawyer/Interval.h>
Classes | |
class | ConstIterator |
Bidirectional forward iterator. More... | |
Public Types | |
typedef T | Value |
Types of values in the interval. | |
typedef ConstIterator | const_iterator |
typedef ConstIterator | iterator |
Public Member Functions | |
Interval () | |
Constructs an empty interval. | |
Interval (const Interval &other) | |
Copy-constructs an interval. | |
Interval (T value) | |
Constructs a singleton interval. | |
Interval & | operator= (const Interval &other) |
Assignment from an interval. | |
Interval & | operator= (T value) |
Assignment from a scalar. | |
T | least () const |
Returns lower limit. | |
T | greatest () const |
Returns upper limit. | |
bool | isEmpty () const |
True if interval is empty. | |
bool | isSingleton () const |
True if interval is a singleton. | |
bool | isWhole () const |
True if interval covers entire space. | |
Value | size () const |
Size of interval. | |
Interval | hull (const Interval &other) const |
Hull. | |
Interval | hull (T value) const |
Hull. | |
std::pair< Interval, Interval > | split (T splitPoint) const |
Split interval in two. | |
Interval | join (const Interval &right) const |
Creates an interval by joining two adjacent intervals. | |
Interval | shiftRightSat (Value n) const |
Shift interval upward. | |
ConstIterator | begin () const |
Iterator positioned at the least value. | |
ConstIterator | end () const |
Iterator positioned one past the greatest value. | |
boost::iterator_range< ConstIterator > | values () const |
Iterator range for values. | |
operator unspecified_bool () const | |
Type for Boolean context. | |
bool | overlaps (const Interval &other) const |
True if two intervals overlap. | |
bool | isOverlapping (const Interval &other) const |
True if two intervals overlap. | |
bool | contains (const Interval &other) const |
Containment predicate. | |
bool | isContaining (const Interval &other) const |
Containment predicate. | |
bool | isLeftAdjacent (const Interval &right) const |
Adjacency predicate. | |
bool | isRightAdjacent (const Interval &left) const |
Adjacency predicate. | |
bool | isAdjacent (const Interval &other) const |
Adjacency predicate. | |
bool | isLeftOf (const Interval &right) const |
Relative position predicate. | |
bool | isRightOf (const Interval &left) const |
Relative position predicate. | |
bool | operator== (const Interval &other) const |
Equality test. | |
bool | operator!= (const Interval &other) const |
Equality test. | |
Interval | intersection (const Interval &other) const |
Intersection. | |
Interval | operator& (const Interval &other) const |
Intersection. | |
Static Public Member Functions | |
static Interval | hull (T v1, T v2) |
Construct an interval from two endpoints. | |
static Interval | baseSize (T lo, T size) |
Construct an interval from one endpoint and a size. | |
static Interval | baseSizeSat (T lo, T size) |
Construct an interval from one endpoint and size, and clip overflows. | |
static Interval | whole () |
Construct an interval that covers the entire domain. | |
static bool | baseSizeOverflows (T base, T size) |
Tests whether a base and size overflows. | |
typedef T Sawyer::Container::Interval< T >::Value |
Types of values in the interval.
Definition at line 34 of file Interval.h.
typedef ConstIterator Sawyer::Container::Interval< T >::const_iterator |
Definition at line 413 of file Interval.h.
typedef ConstIterator Sawyer::Container::Interval< T >::iterator |
Definition at line 414 of file Interval.h.
|
inline |
Constructs an empty interval.
Definition at line 141 of file Interval.h.
|
inline |
Copy-constructs an interval.
Definition at line 144 of file Interval.h.
|
inline |
Constructs a singleton interval.
Definition at line 147 of file Interval.h.
|
inlinestatic |
Construct an interval from two endpoints.
Returns the smallest interal that contains both points.
Definition at line 162 of file Interval.h.
Referenced by Sawyer::Container::Interval< T >::baseSize(), Sawyer::Container::IntervalSetMap< I, S >::erase(), Sawyer::Container::IntervalMap< I, T, Policy >::firstUnmapped(), Sawyer::Container::IntervalMap< I, T, Policy >::hull(), Sawyer::Container::Map< K, T, Cmp, Alloc >::hull(), Sawyer::Container::Set< T, C, A >::hull(), Sawyer::Container::Interval< T >::hull(), Sawyer::Container::Interval< T >::hull(), Sawyer::Container::IntervalSetMap< I, S >::insert(), Sawyer::Container::IntervalMap< I, T, Policy >::insert(), Sawyer::Container::IntervalSet< I >::intersect(), Sawyer::Container::Interval< T >::intersection(), Sawyer::Container::IntervalSet< I >::invert(), Sawyer::Container::IntervalMap< I, T, Policy >::lastUnmapped(), and Sawyer::Container::Interval< T >::split().
|
inlinestatic |
Construct an interval from one endpoint and a size.
Returns the smallest interval that contains lo
(inclusive) through lo
+ size
(exclusive). If size
is zero then an empty interval is created, in which case lo
is irrelevant.
Definition at line 173 of file Interval.h.
References Sawyer::Container::Interval< T >::hull().
Referenced by Rose::BinaryAnalysis::RegisterDescriptor::bits(), and Sawyer::Container::AddressMap< A, T >::write().
|
inlinestatic |
Construct an interval from one endpoint and size, and clip overflows.
Returns the smallest interval that contains lo
(inclusive) through lo
+ size
(exclusvie). If lo
+ size
doesn't fit in an instance of Value then the greatest possible value is used.
Definition at line 182 of file Interval.h.
|
inlinestatic |
Construct an interval that covers the entire domain.
Definition at line 191 of file Interval.h.
Referenced by Sawyer::Container::AddressMap< A, T >::findFreeSpace(), Sawyer::Container::IntervalMap< I, T, Policy >::firstUnmapped(), Sawyer::Container::IntervalSet< I >::invert(), and Sawyer::Container::IntervalMap< I, T, Policy >::lastUnmapped().
|
inline |
Assignment from an interval.
Definition at line 196 of file Interval.h.
|
inline |
Assignment from a scalar.
Definition at line 203 of file Interval.h.
|
inlinestatic |
Tests whether a base and size overflows.
If the base (least value) plus the size would be larger than the maximum possible value, then returns true, otherwise returns false.
Definition at line 212 of file Interval.h.
|
inline |
Returns lower limit.
Definition at line 218 of file Interval.h.
Referenced by Sawyer::Container::DenseIntegerSet< T >::DenseIntegerSet(), Rose::BinaryAnalysis::Strings::EncodedString::address(), Sawyer::Container::AddressMapConstraints< AddressMap >::at(), Sawyer::Container::AddressMap< A, T >::changeAccess(), Sawyer::Container::AddressMap< A, T >::checkConsistency(), Sawyer::Container::BitVectorSupport::compare(), Sawyer::Container::BitVectorSupport::compareSigned(), Sawyer::Container::Interval< T >::contains(), Sawyer::Container::DenseIntegerSet< T >::erase(), Sawyer::Container::DenseIntegerSet< T >::exists(), Sawyer::Container::AddressMap< A, T >::findFreeSpace(), Sawyer::Container::Interval< T >::hull(), Sawyer::Container::DenseIntegerSet< T >::insert(), Sawyer::Container::Interval< T >::intersection(), Sawyer::Container::Interval< T >::isAdjacent(), Sawyer::Container::Interval< T >::isLeftAdjacent(), Sawyer::Container::Interval< T >::isLeftOf(), Sawyer::Container::Interval< T >::join(), Sawyer::Container::IntervalMap< I, T, Policy >::lastUnmapped(), Sawyer::Container::AddressMapConstraints< AddressMap >::print(), Sawyer::Container::AddressMap< A, T >::read(), Sawyer::Container::BitVectorSupport::signExtend(), Sawyer::Container::BitVectorSupport::traverse2(), Sawyer::Container::BitVectorSupport::traverse2(), Sawyer::Container::AddressMapConstraints< AddressMap >::within(), and Sawyer::Container::AddressMap< A, T >::write().
|
inline |
Returns upper limit.
Definition at line 224 of file Interval.h.
Referenced by Sawyer::Container::DenseIntegerSet< T >::DenseIntegerSet(), Sawyer::Container::AddressMapConstraints< AddressMap >::at(), Sawyer::Container::AddressMap< A, T >::checkConsistency(), Sawyer::Container::BitVectorSupport::compare(), Sawyer::Container::BitVectorSupport::compareSigned(), Sawyer::Container::Interval< T >::contains(), Sawyer::Container::AddressMap< A, T >::findFreeSpace(), Sawyer::Container::IntervalMap< I, T, Policy >::firstUnmapped(), Sawyer::Container::Interval< T >::hull(), Sawyer::Container::DenseIntegerSet< T >::insert(), Sawyer::Container::Interval< T >::intersection(), Sawyer::Container::Interval< T >::isAdjacent(), Rose::BinaryAnalysis::Partitioner2::Trigger::isArmed(), Sawyer::Container::Interval< T >::isRightAdjacent(), Sawyer::Container::Interval< T >::isRightOf(), Sawyer::Container::AddressMapConstraints< AddressMap >::print(), Sawyer::Container::BitVectorSupport::signExtend(), and Sawyer::Container::AddressMapConstraints< AddressMap >::within().
|
inline |
True if interval is empty.
Definition at line 230 of file Interval.h.
Referenced by Sawyer::Container::DenseIntegerSet< T >::DenseIntegerSet(), Sawyer::Container::DenseIntegerSet< T >::DenseIntegerSet(), Sawyer::Container::BitVectorSupport::compare(), Sawyer::Container::BitVectorSupport::compareSigned(), Sawyer::Container::Interval< T >::contains(), Sawyer::Container::AddressMap< A, T >::findFreeSpace(), Sawyer::Container::Interval< T >::hull(), Sawyer::Container::DenseIntegerSet< T >::insert(), Sawyer::Container::Interval< T >::intersection(), Sawyer::Container::Interval< T >::isAdjacent(), Rose::BinaryAnalysis::Partitioner2::Trigger::isArmed(), Sawyer::Container::Interval< T >::isLeftAdjacent(), Sawyer::Container::Interval< T >::isLeftOf(), Sawyer::Container::Interval< T >::isRightAdjacent(), Sawyer::Container::Interval< T >::isRightOf(), Sawyer::Container::Interval< T >::join(), Rose::BinaryAnalysis::Variables::StackVariable::operator bool(), Rose::BinaryAnalysis::Variables::GlobalVariable::operator bool(), Rose::BinaryAnalysis::Variables::StackVariable::operator!(), Rose::BinaryAnalysis::Variables::GlobalVariable::operator!(), Sawyer::Container::AddressMapConstraints< AddressMap >::print(), Sawyer::Container::AddressMap< A, T >::read(), Sawyer::Container::BitVectorSupport::signExtend(), Sawyer::Container::BitVectorSupport::traverse2(), Sawyer::Container::BitVectorSupport::traverse2(), Sawyer::Container::AddressMapConstraints< AddressMap >::within(), and Sawyer::Container::AddressMap< A, T >::write().
|
inline |
True if interval is a singleton.
Definition at line 233 of file Interval.h.
|
inline |
True if interval covers entire space.
Definition at line 236 of file Interval.h.
Referenced by Sawyer::Container::Interval< T >::isAdjacent(), and Sawyer::Container::Interval< T >::isRightAdjacent().
|
inline |
True if two intervals overlap.
An empty interval never overlaps with any other interval, empty or not.
Definition at line 243 of file Interval.h.
Referenced by Sawyer::Container::BitVectorSupport::swap().
|
inline |
True if two intervals overlap.
An empty interval never overlaps with any other interval, empty or not.
Definition at line 246 of file Interval.h.
|
inline |
Containment predicate.
Returns true if this interval contains all of the other
interval. An empty interval is always contained in any other interval, even another empty interval.
Definition at line 257 of file Interval.h.
References Sawyer::Container::Interval< T >::greatest(), Sawyer::Container::Interval< T >::isEmpty(), and Sawyer::Container::Interval< T >::least().
Referenced by Rose::BinaryAnalysis::Partitioner2::Trigger::shouldTrigger().
|
inline |
Containment predicate.
Returns true if this interval contains all of the other
interval. An empty interval is always contained in any other interval, even another empty interval.
Definition at line 261 of file Interval.h.
|
inline |
Adjacency predicate.
Returns true if the two intervals are adjacent. An empty interval is adjacent to all other intervals, including another empty interval.
Definition at line 272 of file Interval.h.
References Sawyer::Container::Interval< T >::isEmpty(), and Sawyer::Container::Interval< T >::least().
|
inline |
Adjacency predicate.
Returns true if the two intervals are adjacent. An empty interval is adjacent to all other intervals, including another empty interval.
Definition at line 275 of file Interval.h.
References Sawyer::Container::Interval< T >::greatest(), Sawyer::Container::Interval< T >::isEmpty(), and Sawyer::Container::Interval< T >::isWhole().
|
inline |
Adjacency predicate.
Returns true if the two intervals are adjacent. An empty interval is adjacent to all other intervals, including another empty interval.
Definition at line 278 of file Interval.h.
References Sawyer::Container::Interval< T >::greatest(), Sawyer::Container::Interval< T >::isEmpty(), Sawyer::Container::Interval< T >::isWhole(), and Sawyer::Container::Interval< T >::least().
|
inline |
Relative position predicate.
Returns true if the intervals do not overlap and one is positioned left or right of the other. Empty intervals are considered to be both left and right of the other.
Definition at line 291 of file Interval.h.
References Sawyer::Container::Interval< T >::isEmpty(), and Sawyer::Container::Interval< T >::least().
|
inline |
Relative position predicate.
Returns true if the intervals do not overlap and one is positioned left or right of the other. Empty intervals are considered to be both left and right of the other.
Definition at line 294 of file Interval.h.
References Sawyer::Container::Interval< T >::greatest(), and Sawyer::Container::Interval< T >::isEmpty().
|
inline |
Size of interval.
If the interval is the whole space then the return value is zero due to overflow.
Definition at line 302 of file Interval.h.
Referenced by Sawyer::Container::BitVectorSupport::areEqual(), Sawyer::Container::AddressMap< A, T >::checkConsistency(), Sawyer::Container::BitVectorSupport::compare(), Sawyer::Container::BitVectorSupport::compareSigned(), Sawyer::Container::BitVectorSupport::equalTo(), Sawyer::Container::AddressMap< A, T >::findFreeSpace(), Sawyer::Container::BitVectorSupport::mostSignificantDifference(), Sawyer::Container::AddressMap< A, T >::read(), Sawyer::Container::BitVectorSupport::signExtend(), Rose::BinaryAnalysis::Strings::EncodedString::size(), Sawyer::Container::BitVectorSupport::subtract(), Sawyer::Container::BitVectorSupport::traverse2(), Sawyer::Container::BitVectorSupport::traverse2(), and Sawyer::Container::AddressMap< A, T >::write().
|
inline |
Equality test.
Two intervals are equal if they have the same lower and upper bound, and unequal if either bound differs. Two empty ranges are considered to be equal.
Definition at line 312 of file Interval.h.
|
inline |
Equality test.
Two intervals are equal if they have the same lower and upper bound, and unequal if either bound differs. Two empty ranges are considered to be equal.
Definition at line 315 of file Interval.h.
|
inline |
Intersection.
Returns an interval which is the intersection of this interval with another.
Definition at line 325 of file Interval.h.
References Sawyer::Container::Interval< T >::greatest(), Sawyer::Container::Interval< T >::hull(), Sawyer::Container::Interval< T >::isEmpty(), and Sawyer::Container::Interval< T >::least().
|
inline |
Intersection.
Returns an interval which is the intersection of this interval with another.
Definition at line 330 of file Interval.h.
|
inline |
Hull.
Returns the smallest interval that contains both this interval and the other
interval.
Definition at line 340 of file Interval.h.
References Sawyer::Container::Interval< T >::greatest(), Sawyer::Container::Interval< T >::hull(), Sawyer::Container::Interval< T >::isEmpty(), and Sawyer::Container::Interval< T >::least().
|
inline |
Hull.
Returns the smallest interval that contains both this interval and another value.
Definition at line 353 of file Interval.h.
References Sawyer::Container::Interval< T >::hull().
|
inline |
Split interval in two.
Returns two interval by splitting this interval so that splitPoint
is in the left returned interval. If the split is not a member of this interval then one of the two returned intervals will be empty, depending on whether the split point is less than or greater than this interval. If this interval is empty then both returned intervals will be empty regardless of the split point.
Definition at line 367 of file Interval.h.
References Sawyer::Container::Interval< T >::hull().
|
inline |
Creates an interval by joining two adjacent intervals.
Concatenates this interval with the right
interval and returns the result. This is similar to hull except when neither interval is empty then the greatest value of this interval must be one less than the least value of the right
interval.
Definition at line 386 of file Interval.h.
References Sawyer::Container::Interval< T >::isEmpty(), and Sawyer::Container::Interval< T >::least().
|
inline |
Shift interval upward.
Adds n
to all values of the interval to return a new interval. An empty interval is returned if this interval is empty or adding n
to its least value would overflow. A smaller interval is returned if adding n
to the greatest value would overflow.
Definition at line 402 of file Interval.h.
|
inline |
Iterator positioned at the least value.
Returns an iterator positioned at this interval's least value. If this interval is empty then the returned iterator's atEnd predicate will always return true. Iterators are useful for accessing the values of an interval because they have special logic to avoid arithmetic overflows which can happen if the interval's least and/or greatest value happens to also be the least or greatest value representable by type T. See ConstIterator for details.
Definition at line 423 of file Interval.h.
|
inline |
Iterator positioned one past the greatest value.
Returns an iterator positioned one past this interval's least value even if such a value cannot be represented by type T. If this interval is empty then the returned iterator's atEnd predicate will always return true. Iterators are useful for accessing the values of an interval because they have special logic to avoid arithmetic overflows which can happen if the interval's least and/or greatest value happens to also be the least or greatest value representable by type T. See ConstIterator for details.
Definition at line 434 of file Interval.h.
|
inline |
Iterator range for values.
Definition at line 439 of file Interval.h.
|
inline |
Type for Boolean context.
Implicit conversion to a type that can be used in a boolean context such as an if
or while
statement. For instance:
The inteval evaluates to true if it is non-empty, and false if it is empty.
Definition at line 461 of file Interval.h.