void WriteCurrentCell()
            {
                if ((cCell_area | cCell_cover) != 0)
                {
                    //check cell limit
                    if (m_num_used_cells >= BLOCK_LIMIT)
                    {
                        return;
                    }
                    //------------------------------------------
                    //alloc if required
                    if ((m_num_used_cells + 1) >= m_cells.AllocatedSize)
                    {
                        m_cells = new ArrayList <CellAA>(m_cells, BLOCK_SIZE);
                    }
#if DEBUG
                    //m_cells.SetData(m_num_used_cells, CellAA.dbugCreate(
                    //    cCell_x, cCell_y,
                    //    cCell_cover, cCell_area,
                    //    cCell_left,
                    //    cCell_right));
                    m_cells.SetData(m_num_used_cells, CellAA.Create(
                                        cCell_x, cCell_y,
                                        cCell_cover, cCell_area));
#else
                    m_cells.SetData(m_num_used_cells, CellAA.Create(
                                        cCell_x, cCell_y,
                                        cCell_cover, cCell_area));
#endif
                    m_num_used_cells++;
                }
            }
 public static CellAA Create(int x, int y, int cover, int area)
 {
     CellAA cell = new CellAA();
     cell.x = x;
     cell.y = y;
     cell.cover = cover;
     cell.area = area;
     return cell;
 }
            public static CellAA Create(int x, int y, int cover, int area)
            {
                CellAA cell = new CellAA();

                cell.x     = x;
                cell.y     = y;
                cell.cover = cover;
                cell.area  = area;
                return(cell);
            }
            public static CellAA dbugCreate(int x, int y, int cover, int area, int left, int right)
            {
                CellAA cell = new CellAA(x, y, cover, area);

                //cell.x = x;
                //cell.y = y;
                //cell.cover = cover;
                //cell.area = area;
                cell.dbugLeft  = left;
                cell.dbugRight = right;
                return(cell);
            }
Example #5
0
            public static CellAA Create(int x, int y, int cover, int area, int left, int right)
            {
                CellAA cell = new CellAA();

                cell.x     = x;
                cell.y     = y;
                cell.cover = cover;
                cell.area  = area;
                cell.left  = left;
                cell.right = right;
                return(cell);
            }
            public static CellAA dbugCreate(int x, int y, int cover, int area, int left, int right)
            {
                CellAA cell = new CellAA();
                cell.x = x;
                cell.y = y;
                cell.cover = cover;
                cell.area = area;
#if DEBUG
                cell.dbugLeft = left;
                cell.dbugRight = right;
#endif
                return cell;
            }
            public static CellAA dbugCreate(int x, int y, int cover, int area, int left, int right)
            {
                CellAA cell = new CellAA();

                cell.x     = x;
                cell.y     = y;
                cell.cover = cover;
                cell.area  = area;
#if DEBUG
                cell.dbugLeft  = left;
                cell.dbugRight = right;
#endif
                return(cell);
            }
Example #8
0
                static int GetPivotPoint(CellAA[] dataToSort, int begPoint, int endPoint)
                {
                    int pivot = begPoint;
                    int m     = begPoint + 1;
                    int n     = endPoint;

                    var x_at_PivotPoint = dataToSort[pivot].x;

                    while ((m < endPoint) &&
                           x_at_PivotPoint >= dataToSort[m].x)
                    {
                        m++;
                    }

                    while ((n > begPoint) && (x_at_PivotPoint <= dataToSort[n].x))
                    {
                        n--;
                    }

                    while (m < n)
                    {
                        //swap data between m and n
                        CellAA temp = dataToSort[m];
                        dataToSort[m] = dataToSort[n];
                        dataToSort[n] = temp;

                        while ((m < endPoint) && (x_at_PivotPoint >= dataToSort[m].x))
                        {
                            m++;
                        }

                        while ((n > begPoint) && (x_at_PivotPoint <= dataToSort[n].x))
                        {
                            n--;
                        }
                    }

                    if (pivot != n)
                    {
                        CellAA temp2 = dataToSort[n];
                        dataToSort[n]     = dataToSort[pivot];
                        dataToSort[pivot] = temp2;
                    }
                    return(n);
                }
Example #9
0
        private uint GetPivotPoint(CellAA[] dataToSort, uint begPoint, uint endPoint)
        {
            uint pivot = begPoint;
            uint m     = begPoint + 1;
            uint n     = endPoint;

            while ((m < endPoint) &&
                   dataToSort[pivot].X >= dataToSort[m].X)
            {
                m++;
            }

            while ((n > begPoint) && (dataToSort[pivot].X <= dataToSort[n].X))
            {
                n--;
            }
            while (m < n)
            {
                CellAA temp = dataToSort[m];
                dataToSort[m] = dataToSort[n];
                dataToSort[n] = temp;

                while ((m < endPoint) && (dataToSort[pivot].X >= dataToSort[m].X))
                {
                    m++;
                }

                while ((n > begPoint) && (dataToSort[pivot].X <= dataToSort[n].X))
                {
                    n--;
                }
            }
            if (pivot != n)
            {
                CellAA temp2 = dataToSort[n];
                dataToSort[n]     = dataToSort[pivot];
                dataToSort[pivot] = temp2;
            }
            return(n);
        }
                static int GetPivotPoint(CellAA[] dataToSort, int begPoint, int endPoint)
                {
                    int pivot = begPoint;
                    int m = begPoint + 1;
                    int n = endPoint;
                    var x_at_PivotPoint = dataToSort[pivot].x;
                    while ((m < endPoint)
                        && x_at_PivotPoint >= dataToSort[m].x)
                    {
                        m++;
                    }

                    while ((n > begPoint) && (x_at_PivotPoint <= dataToSort[n].x))
                    {
                        n--;
                    }

                    while (m < n)
                    {
                        //swap data between m and n
                        CellAA temp = dataToSort[m];
                        dataToSort[m] = dataToSort[n];
                        dataToSort[n] = temp;
                        while ((m < endPoint) && (x_at_PivotPoint >= dataToSort[m].x))
                        {
                            m++;
                        }

                        while ((n > begPoint) && (x_at_PivotPoint <= dataToSort[n].x))
                        {
                            n--;
                        }
                    }

                    if (pivot != n)
                    {
                        CellAA temp2 = dataToSort[n];
                        dataToSort[n] = dataToSort[pivot];
                        dataToSort[pivot] = temp2;
                    }
                    return n;
                }
                public static void Sort(CellAA[] dataToSort, int beg, int end)
                {
                    if (end == beg)
                    {
                        return;
                    }
                    else
                    {
                        int pivot = GetPivotPoint(dataToSort, beg, end);
                        if (pivot > beg)
                        {
                            Sort(dataToSort, beg, pivot - 1);
                        }

                        if (pivot < end)
                        {
                            Sort(dataToSort, pivot + 1, end);
                        }
                    }
                }
 public static void Sort(CellAA[] dataToSort)
 {
     Sort(dataToSort, 0, dataToSort.Length - 1);
 }
 public void GetCells(int y, out CellAA[] cellData, out int offset, out int num)
 {
     cellData = m_sorted_cells.Array;
     SortedY d = m_sorted_y[y - m_min_y];
     offset = d.start;
     num = d.num;
 }