-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathReflectionsSet.cs
32 lines (30 loc) · 912 Bytes
/
ReflectionsSet.cs
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
28
29
30
31
32
using System.Collections.Generic;
using DotNetTransformer.Extensions;
using DotNetTransformer.Math.Permutation;
namespace DotNetTransformer.Math.Transform {
internal sealed class ReflectionsSet<T, P> : FlipRotateSet<T, P>
where T : IFlipRotate<T, P>, new()
where P : IPermutation<P>, new()
{
public ReflectionsSet(byte dimensions, Constructor<T, P, int> ctor) : base(dimensions, ctor) { }
public override SetType Type { get { return SetType.Reflections; } }
public override long Count {
get {
return base.Count >> 1;
}
}
public override bool Contains(T item) {
return base.Contains(item) && item.IsReflection;
}
public override IEnumerator<T> GetEnumerator() {
int c = 1 << _dim;
P i = new P();
foreach(P p in i.GetRange<P>(i, _dim)) {
int s = p.SwapsCount;
for(int v = 0; v < c; ++v)
if(!IsRotational(s, v))
yield return _ctor(p, v);
}
}
}
}