Пример #1
0
        public State NextSibling()
        {
            var next = new State(Parent, this);

            if (next.GuaranteedUpperIndex >= 0)
                return next;

            return null;
        }
Пример #2
0
        public State(List<Password> passwords, State prevSibling)
        {
            _observedPasswords = passwords;
            _currentPassword = passwords[0];
            _children = new List<State>();
            //GuaranteedUpperIndex = GuaranteedLowerIndex = GuaranteedNumericIndex = GuaranteedSpecialIndex = -1;

            Initialize(prevSibling);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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();
        }
Пример #5
0
        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);
            }
        }
Пример #6
0
        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);
            }
        }