public State NextSibling() { var next = new State(Parent, this); if (next.GuaranteedUpperIndex >= 0) return next; return null; }
public State(List<Password> passwords, State prevSibling) { _observedPasswords = passwords; _currentPassword = passwords[0]; _children = new List<State>(); //GuaranteedUpperIndex = GuaranteedLowerIndex = GuaranteedNumericIndex = GuaranteedSpecialIndex = -1; Initialize(prevSibling); }
public State(State parent, State prevSibling) { if (parent != null) { _parent = parent; _observedPasswords = parent.ObservedPasswords; _observedPasswordIndex = parent.ObservedPasswordIndex + 1; _currentPassword = ObservedPasswords[ObservedPasswordIndex]; } else { _observedPasswords = prevSibling.ObservedPasswords; _currentPassword = ObservedPasswords[0]; } _children = new List<State>(); Initialize(prevSibling); }
protected void Initialize(State prevSibling) { if (prevSibling != null) { GuaranteedUpperIndex = prevSibling.GuaranteedUpperIndex; GuaranteedLowerIndex = prevSibling.GuaranteedLowerIndex; GuaranteedNumericIndex = prevSibling.GuaranteedNumericIndex; GuaranteedSpecialIndex = prevSibling.GuaranteedSpecialIndex + 1; SetGuaranteed(); } if (GuaranteedUpperIndex >= 0) UpdatePredictor(); }
private static void AddChildren(State state, int level) { if (level > 1) { foreach (var ch in state.Children) AddChildren(ch, level - 1); return; } var child = new State(state, null); stateCount++; if(!child.ImpossibleState) state.Children.Add(child); while ((child = child.NextSibling()) != null) { stateCount++; if(!child.ImpossibleState) state.Children.Add(child); } }
private static void AddSiblings(List<State> states, State state) { if(!state.ImpossibleState) states.Add(state); while ((state = state.NextSibling()) != null) { if(!state.ImpossibleState) states.Add(state); } }