addr_range_map.hh (9405:c0a0593510db) | addr_range_map.hh (9409:e399b6c18b76) |
---|---|
1/* 2 * Copyright (c) 2012 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 54 unchanged lines hidden (view full) --- 63 64 public: 65 typedef typename RangeMap::iterator iterator; 66 typedef typename RangeMap::const_iterator const_iterator; 67 68 const_iterator 69 find(const AddrRange &r) const 70 { | 1/* 2 * Copyright (c) 2012 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 54 unchanged lines hidden (view full) --- 63 64 public: 65 typedef typename RangeMap::iterator iterator; 66 typedef typename RangeMap::const_iterator const_iterator; 67 68 const_iterator 69 find(const AddrRange &r) const 70 { |
71 const_iterator i; | 71 if (tree.empty()) 72 return tree.end(); |
72 | 73 |
73 i = tree.upper_bound(r); | 74 const_iterator i = tree.upper_bound(r); |
74 75 if (i == tree.begin()) { 76 if (i->first.intersects(r)) 77 return i; 78 else 79 // Nothing could match, so return end() 80 return tree.end(); 81 } 82 83 --i; 84 85 if (i->first.intersects(r)) 86 return i; 87 88 return tree.end(); 89 } 90 | 75 76 if (i == tree.begin()) { 77 if (i->first.intersects(r)) 78 return i; 79 else 80 // Nothing could match, so return end() 81 return tree.end(); 82 } 83 84 --i; 85 86 if (i->first.intersects(r)) 87 return i; 88 89 return tree.end(); 90 } 91 |
91 iterator 92 find(const AddrRange &r) 93 { 94 iterator i; 95 96 i = tree.upper_bound(r); 97 98 if (i == tree.begin()) { 99 if (i->first.intersects(r)) 100 return i; 101 else 102 // Nothing could match, so return end() 103 return tree.end(); 104 } 105 106 --i; 107 108 if (i->first.intersects(r)) 109 return i; 110 111 return tree.end(); 112 } 113 | |
114 const_iterator 115 find(const Addr &r) const 116 { 117 return find(RangeSize(r, 1)); 118 } 119 | 92 const_iterator 93 find(const Addr &r) const 94 { 95 return find(RangeSize(r, 1)); 96 } 97 |
120 iterator 121 find(const Addr &r) 122 { 123 return find(RangeSize(r, 1)); 124 } 125 | |
126 bool | 98 bool |
127 intersect(const AddrRange &r) | 99 intersect(const AddrRange &r) const |
128 { | 100 { |
129 iterator i; 130 i = find(r); 131 if (i != tree.end()) 132 return true; 133 return false; | 101 return find(r) != tree.end(); |
134 } 135 | 102 } 103 |
136 iterator | 104 const_iterator |
137 insert(const AddrRange &r, const V& d) 138 { 139 if (intersect(r)) 140 return tree.end(); 141 142 return tree.insert(std::make_pair(r, d)).first; 143 } 144 | 105 insert(const AddrRange &r, const V& d) 106 { 107 if (intersect(r)) 108 return tree.end(); 109 110 return tree.insert(std::make_pair(r, d)).first; 111 } 112 |
145 std::size_t 146 erase(Addr k) 147 { 148 return tree.erase(k); 149 } 150 | |
151 void 152 erase(iterator p) 153 { 154 tree.erase(p); 155 } 156 157 void 158 erase(iterator p, iterator q) --- 48 unchanged lines hidden --- | 113 void 114 erase(iterator p) 115 { 116 tree.erase(p); 117 } 118 119 void 120 erase(iterator p, iterator q) --- 48 unchanged lines hidden --- |