コード例 #1
0
 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);
        }