예제 #1
0
파일: GridSquare.cs 프로젝트: gg12123/Snake
    public void Init(int xIndex, int yIndex, ContainerPointer node)
    {
        XIndex = xIndex;
        YIndex = yIndex;

        Node             = node;
        m_Renderer.color = m_FreeColour;
    }
예제 #2
0
    public MyContainer(int size)
    {
        m_Values   = new T[size];
        m_Pointers = new ContainerPointer[size];

        for (int i = 0; i < size; i++)
        {
            m_Pointers[i] = new ContainerPointer(i);
        }

        Count = 0;
    }
예제 #3
0
    public void Remove(ContainerPointer pointer)
    {
        int newFree = pointer.Index;
        int end     = Count - 1;

        // Move end pointer to the free slot
        m_Pointers[newFree]       = m_Pointers[end];
        m_Pointers[newFree].Index = newFree;

        // Move end value
        m_Values[newFree] = m_Values[end];

        // Put the old pointer at the end
        m_Pointers[end]       = pointer;
        m_Pointers[end].Index = end;

        // Null the end value
        m_Values[end] = default(T);

        Count--;
    }
예제 #4
0
 public T GetValue(ContainerPointer p)
 {
     return(m_Values[p.Index]);
 }