MCPcopy Create free account
hub / github.com/AdaptiveCpp/AdaptiveCpp / intersections_with

Method intersections_with

src/runtime/data.cpp:96–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

94{ return _size; }
95
96void range_store::intersections_with(const rect& r,
97 data_state desired_state,
98 std::vector<rect>& out) const
99{
100 out.clear();
101
102 id<3> rect_begin = r.first;
103 id<3> rect_max =
104 rect_begin + id<3>{r.second[0], r.second[1], r.second[2]};
105
106
107 std::vector<data_state> visited_entries(_contained_data.size(), data_state::empty);
108
109 this->for_each_element_in_range(r, [&](id<3> pos, const data_state& entry){
110 size_t linear_pos = get_index(pos);
111 // Look for a potential new rect, if
112 // * the starting position is of the state desired by the user
113 // * the start position isn't covered already by another rect
114 // that was found previously
115 if(entry == desired_state &&
116 visited_entries[linear_pos] == data_state::empty) {
117
118 // Find the largest contiguous rect for which all entries
119 // are both of \c desired_state and unvisited
120 range<3> rect_size =
121 find_max_contiguous_rect_extent(pos, rect_max,
122 [this,&visited_entries,desired_state](size_t linear_pos){
123 return this->_contained_data[linear_pos] == desired_state
124 && visited_entries[linear_pos] == data_state::empty;
125 });
126
127 rect found_rect = std::make_pair(pos, rect_size);
128 out.push_back(found_rect);
129
130 // Mark all pages inside the rect as visited
131 this->for_each_element_in_range(
132 found_rect,
133 visited_entries,
134 [&](id<3> pos, data_state& entry){
135
136 entry = data_state::available;
137 });
138 }
139 });
140}
141
142bool range_store::entire_range_equals(
143 const rect& r, data_state desired_state) const

Callers 1

BOOST_AUTO_TEST_CASEFunction · 0.45

Calls 4

push_backMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected