Ejemplo n.º 1
0
        static void TestWord()
        {
            GrayWord gw = new GrayWord();

            gw.zero(4);
            Debug.Assert(gw.isEmpty());
            gw.negate(1);
            Debug.Assert(gw.ToString().Equals("0, 1, 0, 0"));
            Debug.Assert(gw.findFirst1() == 1);
            Debug.Assert(!gw.isEmpty());
            Debug.Assert(gw.getHowMany() == 1);
            gw.negate(2);
            Debug.Assert(gw.getHowMany() == 2);
        }
Ejemplo n.º 2
0
        public void generateCode(int n)
        {
            GrayWord newWord;

            numberOfWords = powerOf2(n);

            _result = new List <GrayWord>();
            for (int i = 0; i < numberOfWords; i++)
            {
                //if (_result[i] == null)
                if (_result.Count() <= i)
                {
                    newWord = new GrayWord();
                    newWord.zero(n);
                    _result.Add(newWord);
                }
                if (i > 0)
                {
                    succ_next(i);
                }
            }
            //for (int i = 1; i < numberOfWords; i++)
            //    succ_next(i);
        }