diff options
| author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2021-07-29 12:00:18 +0000 |
|---|---|---|
| committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2022-04-10 18:13:31 +0000 |
| commit | 9f786f0550b6d267aabf79364b802f0fadc9629d (patch) | |
| tree | ee5de1aa54fbee40cb47b375400e34e789e9b982 /contrib | |
| parent | f49fc9b4876382d5c6f08fd7a6125b554c49e260 (diff) | |
| download | monzero-core-9f786f0550b6d267aabf79364b802f0fadc9629d.tar.gz monzero-core-9f786f0550b6d267aabf79364b802f0fadc9629d.tar.xz monzero-core-9f786f0550b6d267aabf79364b802f0fadc9629d.zip | |
epee: allow copying a rolling_median_t object
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/epee/include/rolling_median.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/contrib/epee/include/rolling_median.h b/contrib/epee/include/rolling_median.h index 8965a8268..e230fd974 100644 --- a/contrib/epee/include/rolling_median.h +++ b/contrib/epee/include/rolling_median.h @@ -126,7 +126,6 @@ private: protected: rolling_median_t &operator=(const rolling_median_t&) = delete; - rolling_median_t(const rolling_median_t&) = delete; public: //creates new rolling_median_t: to calculate `nItems` running median. @@ -139,6 +138,20 @@ public: clear(); } + rolling_median_t(const rolling_median_t &other) + { + N = other.N; + int size = N * (sizeof(Item) + sizeof(int) * 2); + data = (Item*)malloc(size); + memcpy(data, other.data, size); + pos = (int*) (data + N); + heap = pos + N + (N / 2); //points to middle of storage. + idx = other.idx; + minCt = other.minCt; + maxCt = other.maxCt; + sz = other.sz; + } + rolling_median_t(rolling_median_t &&m) { memcpy(this, &m, sizeof(rolling_median_t)); |
