Skip to content

Commit

Permalink
set default init for i. use rolling in expanding
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoralez committed May 6, 2024
1 parent 4a1ba1c commit d635d45
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/expanding.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ inline void ExpandingStdTransform(const T *data, int n, T *out, T *agg) {

template <typename T> struct ExpandingMinTransform {
void operator()(const T *data, int n, T *out) {
RollingCompTransform<T, std::greater_equal<T>>(data, n, out, n, 1);
RollingMinTransform<T>()(data, n, out, n, 1);
}
};

template <typename T> struct ExpandingMaxTransform {
void operator()(const T *data, int n, T *out) {
RollingCompTransform<T, std::less_equal<T>>(data, n, out, n, 1);
RollingMaxTransform<T>()(data, n, out, n, 1);
}
};

Expand Down
4 changes: 2 additions & 2 deletions include/rolling.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ template <typename T> struct ValWithIdx {
template <typename T, typename Comp> class SortedDeque {
public:
SortedDeque(int window_size, Comp comp = Comp())
: window_size_(window_size), i_(-1), comp_(comp) {}
: window_size_(window_size), comp_(comp) {}
void Update(T x) {
while (!buffer_.empty() && comp_(buffer_.back().val, x)) {
buffer_.pop_back();
Expand All @@ -93,7 +93,7 @@ template <typename T, typename Comp> class SortedDeque {
private:
std::deque<ValWithIdx<T>> buffer_;
int window_size_;
int i_;
int i_ = -1;
Comp comp_;
};

Expand Down

0 comments on commit d635d45

Please sign in to comment.