MapSetVars

A wrapper around a MapSetVisitor which allows interacting with it using a more conventional interface.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

Set
alias Set = MapSet!(VarName, Value, nullValue)
Undocumented in source.
Value
alias Value = Value_
Undocumented in source.
VarName
alias VarName = VarName_
Undocumented in source.
Visitor
alias Visitor = MapSetVisitor!(VarName, Value, nullValue)
Undocumented in source.
opIndex
alias opIndex = get
Undocumented in source.

Functions

allocate
Var allocate(Value value)
Undocumented in source. Be warned that the author may not have intended to support it.
get
Var get(VarName name)
Undocumented in source. Be warned that the author may not have intended to support it.
inject
Var inject(Value[] values)
Undocumented in source. Be warned that the author may not have intended to support it.
next
bool next()
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

var
Dispatcher var [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

Var
struct Var
Undocumented in source.

Variables

varCounter
VarName varCounter;
Undocumented in source.
visitor
Visitor visitor;
Undocumented in source.

Examples

An example. Note that, unlike the similar Visitor test case, this iterates only once, thanks to the opBinary support.

	// Setup

	enum VarName : uint { x, y, z, tempVarStart = 100, tempVarEnd = 200 }
	MapSetVars!(VarName, int) v;
	alias M = MapSetVars!(VarName, int).Set;
	M m = v.Set.unitSet;
	m = m.cartesianProduct(VarName.x, [1, 2, 3]);
	m = m.cartesianProduct(VarName.y, [10, 20, 30]);
    v.visitor = v.Visitor(m);

	// The algorithm that runs on the mapset

	void theAlgorithm()
	{
		v.var.z = v.var.x + v.var.y;
	}

	// The evaluation loop

	M results;
	size_t numIterations;
	while (v.next())
	{
		theAlgorithm();

		results = results.merge(v.visitor.currentSubset);
		numIterations++;
	}

	assert(numIterations == 1);
	assert(results.all(VarName.z) == [11, 12, 13, 21, 22, 23, 31, 32, 33]);

Meta