Range.h revision b1fb72761226817e7f687eca21cbe9c0a3ec4cf6
1//===--------------------- Range.h ------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef utility_Range_h_
11#define utility_Range_h_
12
13#include <stdint.h>
14#include <algorithm>
15
16namespace lldb_utility {
17
18class Range
19{
20public:
21
22    typedef uint64_t ValueType;
23
24    static const ValueType OPEN_END = UINT64_MAX;
25
26    Range (const Range& rng);
27
28    Range (ValueType low = 0,
29           ValueType high = OPEN_END);
30
31    Range&
32    operator = (const Range& rhs);
33
34    ValueType
35    GetLow ()
36    {
37        return m_low;
38    }
39
40    ValueType
41    GetHigh ()
42    {
43        return m_high;
44    }
45
46    void
47    SetLow (ValueType low)
48    {
49        m_low = low;
50    }
51
52    void
53    SetHigh (ValueType high)
54    {
55        m_high = high;
56    }
57
58    void
59    Flip ();
60
61    void
62    Intersection (const Range& other);
63
64    void
65    Union (const Range& other);
66
67    typedef bool (*RangeCallback)(ValueType index);
68
69    void
70    Iterate (RangeCallback callback);
71
72    ValueType
73    GetSize ();
74
75    bool
76    IsEmpty ();
77
78private:
79
80    void
81    InitRange ();
82
83    ValueType m_low;
84    ValueType m_high;
85};
86
87} // namespace lldb_private
88
89#endif // #ifndef utility_Range_h_
90