public void testIntArray()
        {
            DynamicIntArray dia = new DynamicIntArray(10);

            for (int i = 0; i < 10000; ++i)
            {
                dia.add(2 * i);
            }
            Assert.Equal(10000, dia.size());
            for (int i = 0; i < 10000; ++i)
            {
                Assert.Equal(2 * i, dia.get(i));
            }
            dia.clear();
            Assert.Equal(0, dia.size());
            dia.add(3);
            dia.add(12);
            dia.add(65);
            Assert.Equal("{3,12,65}", dia.ToString());
            for (int i = 0; i < 5; ++i)
            {
                dia.increment(i, 3);
            }
            Assert.Equal("{6,15,68,3,3}", dia.ToString());
        }
Exemplo n.º 2
0
 /**
  * Is the given node red as opposed to black? To prevent having an extra word
  * in the data array, we just the low bit on the left child index.
  */
 protected internal bool isRed(int position)
 {
     return(position != NULL &&
            (data.get(position * ELEMENT_SIZE + LEFT_OFFSET) & 1) == 1);
 }