nk
1.0.0
C++ Numerical Computing Runtime
Toggle main menu visibility
Loading...
Searching...
No Matches
elem_regions.hpp
1
27
28
#pragma once
29
30
#include <cstddef>
31
#include <map>
32
#include <string>
33
#include <vector>
34
35
namespace
nk {
36
38
struct
ElemRegion
39
{
40
size_t
r0 = 1, r1 = 0, c0 = 1, c1 = 0;
41
42
bool
empty()
const
{
return
r1 < r0 || c1 < c0; }
43
bool
intersects(
const
ElemRegion
&o)
const
44
{
45
return
!empty() && !o.empty() && r0 <= o.r1 && o.r0 <= r1
46
&& c0 <= o.c1 && o.c0 <= c1;
47
}
48
};
49
52
struct
VarRegions
53
{
54
bool
all =
false
;
55
std::vector<ElemRegion> rects;
56
57
void
setAll() { all =
true
; }
58
void
add(
const
ElemRegion
&r)
59
{
60
if
(!r.empty())
61
rects.push_back(r);
62
}
64
bool
touches
(
const
ElemRegion
&r)
const
65
{
66
if
(all)
67
return
true
;
68
for
(
const
auto
&x : rects)
69
if
(x.intersects(r))
70
return
true
;
71
return
false
;
72
}
73
bool
touchesAll()
const
{
return
all || !rects.empty(); }
74
};
75
78
using
ElemAccessMap = std::map<std::string, VarRegions>;
79
80
}
// namespace nk
nk::ElemRegion
One rectangle, inclusive 1-based bounds. Empty (r1 < r0) = nothing.
Definition
elem_regions.hpp:39
nk::VarRegions
The set of regions accessed on ONE variable by one statement.
Definition
elem_regions.hpp:53
nk::VarRegions::touches
bool touches(const ElemRegion &r) const
True when this access set could touch r (or a superset of it).
Definition
elem_regions.hpp:64
src
core
include
nk
core
elem_regions.hpp
Generated by
1.17.0