1 //===--------------------- Range.cpp -----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Utility/Range.h"
12 using namespace lldb_utility;
14 Range::Range (const Range& rng) :
21 Range::Range (Range::ValueType low,
22 Range::ValueType high) :
32 if (m_low == OPEN_END)
34 if (m_high == OPEN_END)
38 // make an empty range
46 Range::operator = (const Range& rhs)
50 this->m_low = rhs.m_low;
51 this->m_high = rhs.m_high;
59 std::swap(m_high, m_low);
63 Range::Intersection (const Range& other)
65 m_low = std::max(m_low,other.m_low);
66 m_high = std::min(m_high,other.m_high);
70 Range::Union (const Range& other)
72 m_low = std::min(m_low,other.m_low);
73 m_high = std::max(m_high,other.m_high);
77 Range::Iterate (RangeCallback callback)
79 ValueType counter = m_low;
80 while (counter <= m_high)
82 bool should_continue = callback(counter);
92 return (m_low > m_high);
98 if (m_high == OPEN_END)
101 return m_high - m_low + 1;