Skip to content

Commit

Permalink
simplify; modernise constructs, defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
nilason committed Dec 7, 2022
1 parent b0d659e commit babaf35
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 42 deletions.
12 changes: 6 additions & 6 deletions raster/r.terraflow/ccforest.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ class keyvalue {
keyvalue() : key(-1), value(-1) {};
keyvalue(T vk, T vv) : key(vk), value(vv) {};

keyvalue(const keyvalue &) = default;
keyvalue &operator=(const keyvalue &) = default;
keyvalue(keyvalue &&) = default;
keyvalue &operator=(keyvalue &&) = default;
~keyvalue() = default;

T getPriority() const { return key; };
T getValue() const { return value; };
T src() const { return key; };
Expand Down Expand Up @@ -133,9 +127,15 @@ class ccforest {
int foundAllRoots;
cckeyvalue savedRoot;
int savedRootValid;

public:
ccforest();
ccforest(const ccforest &) = delete;
ccforest &operator=(const ccforest &) = delete;
ccforest(ccforest &&) = delete;
ccforest &operator=(ccforest &&) = delete;
~ccforest();

void insert(const T& i, const T& j); /* insert edge (i,j) */
T findNextRoot(const T& i); /* find root where i >= prev i */
void printRootStream();
Expand Down
9 changes: 0 additions & 9 deletions raster/r.terraflow/genericWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,6 @@ class genericWindow {
}
}

genericWindow<T> &operator=(const genericWindow<T> &) = default;

/***************************************************************/
genericWindow(const genericWindow<T> &win) {
for (int i=0;i<9;i++) {
data[i] = win.data[i];
}
}

/***************************************************************/
/* get specified neighbour di,dj in {-1,0,1} */
T get(short di, short dj) const {
Expand Down
44 changes: 17 additions & 27 deletions raster/r.terraflow/sweep.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,20 @@ class gridPosition {
/*************************************************************/
class flowPriority {
public:
elevation_type h;
toporank_type toporank;
elevation_type h{0.0};
toporank_type toporank{0};
/* points at same heights are processed in increasing order of their
topological rank; overall, this gives topological order and
guarantees that flow is never puhsed backwards. Note: of course,
this is a way of waving hands on topological sorting. */
dimension_type i,j;
dimension_type i{0}, j{0};

public:
flowPriority(elevation_type a = 0, toporank_type b = 0,
dimension_type c = 0, dimension_type d = 0)
: h(a), toporank(b), i(c), j(d)
flowPriority() {}
flowPriority(elevation_type a) : h{a} {}
flowPriority(elevation_type a, toporank_type b, dimension_type c,
dimension_type d)
: h{a}, toporank{b}, i{c}, j{d}
{
}

Expand All @@ -189,7 +191,7 @@ class flowPriority {
flowPriority(flowPriority &&) = default;
flowPriority &operator=(flowPriority &&) = default;
~flowPriority() = default;

elevation_type field1() const {
return h;
}
Expand Down Expand Up @@ -431,16 +433,11 @@ class PrioCmpSweepItem {
/************************************************************/
class flowValue {
public:
flowaccumulation_type value;
flowaccumulation_type value{0};

public:
flowValue(flowaccumulation_type x=0): value(x) {}

flowValue(const flowValue &) = default;
flowValue &operator=(const flowValue &) = default;
flowValue(flowValue &&) = default;
flowValue &operator=(flowValue &&) = default;
~flowValue() = default;
flowValue() {}
flowValue(flowaccumulation_type x) : value{x} {}

flowaccumulation_type get() const {
return value;
Expand Down Expand Up @@ -486,22 +483,15 @@ class flowValue {
/************************************************************/
class flowStructure {
private:
flowPriority prio;
flowValue val;
flowPriority prio{};
flowValue val{};

public:

flowStructure(const flowPriority &p = 0, const flowValue &e = 0)
: prio(p), val(e)
flowStructure() {}
flowStructure(const flowPriority &p, const flowValue &e) : prio{p}, val{e}
{
}

flowStructure(const flowStructure &) = default;
flowStructure &operator=(const flowStructure &) = default;
flowStructure(flowStructure &&) = default;
flowStructure &operator=(flowStructure &&) = default;
~flowStructure() = default;

flowPriority getPriority() const {
return prio;
}
Expand Down

0 comments on commit babaf35

Please sign in to comment.