public bool IteratorHasValues(ISegmentIterator iterator, int[] values)
 {
     foreach (int value in values)
     {
         if (value != iterator.GetCurrent().Value)
         {
             return(false);
         }
         iterator.Next();
     }
     return(true);
 }
예제 #2
0
        private void BuildValueList(ISegmentIterator iterator)
        {
            _values = new List <int>();

            iterator.First();
            while (!iterator.IsDone())
            {
                var value = iterator.GetCurrent().Value;
                if (value != CellValue.Unknown.Value)
                {
                    _values.Add(value);
                }

                iterator.Next();
            }
        }
예제 #3
0
        private bool Reduce(ISegmentIterator iterator)
        {
            var finished = true;

            iterator.First();
            while (!iterator.IsDone())
            {
                var cell = iterator.GetCurrent();

                foreach (int v in _values)
                {
                    if (cell.RemoveCandidate(v))
                    {
                        finished = false;
                    }
                }

                iterator.SetCurrent(cell);

                iterator.Next();
            }
            return(finished);
        }
예제 #4
0
        public bool Execute(ISegmentIterator iterator)
        {
            _values = new List <int>();

            iterator.First();
            while (!iterator.IsDone())
            {
                var cell = iterator.GetCurrent();

                if (cell.Value != CellValue.Unknown.Value)
                {
                    if (_values.Exists(x => x == cell.Value))
                    {
                        _validated = false;
                        return(false);
                    }
                    _values.Add(cell.Value);
                }

                iterator.Next();
            }
            _validated = true;
            return(true);
        }