diff options
author | randomdan <randomdan@localhost> | 2013-03-28 17:51:07 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2013-03-28 17:51:07 +0000 |
commit | 69fbeed3ad3812f66db21bce52ef06f1f0549579 (patch) | |
tree | c0beaf7e9aad6fd55bfd6a88203f874e188b126b /project2/basics/aggregates/min.cpp | |
parent | A stream processing module that reads sets of name=value pairs (diff) | |
download | project2-69fbeed3ad3812f66db21bce52ef06f1f0549579.tar.bz2 project2-69fbeed3ad3812f66db21bce52ef06f1f0549579.tar.xz project2-69fbeed3ad3812f66db21bce52ef06f1f0549579.zip |
skip 1 shuffle of code out of common
Diffstat (limited to 'project2/basics/aggregates/min.cpp')
-rw-r--r-- | project2/basics/aggregates/min.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/project2/basics/aggregates/min.cpp b/project2/basics/aggregates/min.cpp new file mode 100644 index 0000000..ee0bf3d --- /dev/null +++ b/project2/basics/aggregates/min.cpp @@ -0,0 +1,32 @@ +#include <aggregate.h> + +class Min : public ValueAggregate { + public: + Min(ScriptNodePtr s) : + ValueAggregate(s), + first(true) + { + } + void reset() const + { + result = VariableType(); + first = true; + } + void pushValue(const VariableType & v) const + { + if (first || v < result) { + result = v; + } + first = false; + } + VariableType resultValue() const + { + return result; + } + private: + mutable VariableType result; + mutable bool first; +}; + +DECLARE_LOADER("min", Min); + |