summaryrefslogtreecommitdiff
path: root/project2/basics/aggregates/distinct.cpp
blob: 33d71b00994bad34ae3e06e71fda2a1971aee0e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <aggregate.h>

class Distinct : public SetAggregate {
	public:
		Distinct(ScriptNodePtr s) :
			SetAggregate(s)
		{
		}
		void reset() const
		{
			result.clear();
		}
		void pushValue(const VariableType & v, ExecContext *) const
		{
			result.insert(v);
		}
		void onResultValues(const SetAggregate::UseAgg & u) const
		{
			for (const VariableType & v : result) {
				u(v);
			}
		}
	private:
		mutable std::set<VariableType> result;
};

DECLARE_LOADER("distinct", Distinct);