public static int[] GetSetIndices(this UInt64 set) { int[] indices = new int[set.BitCount()]; int count = 0; for (int i = 0; i < MaxSize - 1; i++) { if (set.ContainsIndex(i)) { indices[count] = i; count++; } } return(indices); }
// we override 'narrowed' here because there is no narrowing to be done in 'update variable'. This is a boolean test. internal override void Narrowed(Variable narrowedVariable, out bool success) { int possible = 0; int definite = 0; for (int i = 0; i < Variables.Length; i++) { var variable = Variables[i]; if ((_set & variable.AllowableValues) != 0UL) { possible++; if (variable.IsUnique) { definite++; } } } if (possible < MinOccurences || definite > MaxOccurences) { success = false; return; } else if (definite == MaxOccurences) { foreach (var variable in Variables) { UInt64 value = variable.AllowableValues; if (value.BitCount() > 1) { variable.NarrowTo(~_set, out success); if (!success) { return; } } } } success = true; return; }