当前位置: 首页>>代码示例>>C#>>正文


C# DynamicArray.Clear方法代码示例

本文整理汇总了C#中DynamicArray.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# DynamicArray.Clear方法的具体用法?C# DynamicArray.Clear怎么用?C# DynamicArray.Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DynamicArray的用法示例。


在下文中一共展示了DynamicArray.Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            var array = new DynamicArray<string>();
            array.Add("Georgi");
            array.Add("Nikolai");
            Console.WriteLine(array.IndexOf("Nikolai"));
            Console.WriteLine(array.Cointains("Kiril"));
            array.Remove("Georgi");
            array.InsertAt(1, "Ivan");
            array.Clear();
            Console.WriteLine(array.Capacity);
            Console.WriteLine(array.Count);

            array.Add("Stefan");
            array.Add("Krum");
            var arr = array.ToArray();
            Console.WriteLine();
            foreach (var item in array)
            {
                Console.WriteLine(item);
            }
            Console.WriteLine();

            foreach (var item in arr)
            {
                Console.WriteLine(item);
            }
        }
开发者ID:Redsart,项目名称:Hack-Bulgaria,代码行数:28,代码来源:Program.cs

示例2: Main

 public static void Main()
 {
     DynamicArray<string> arrey = new DynamicArray<string>();
     arrey.Add("Pesho");
     arrey.Add("Gosho");
     Console.WriteLine(arrey.IndexOf("Pesho"));
     Console.WriteLine(arrey.Contains("Gosho"));
     Console.WriteLine(arrey.Contains("Ivan"));
     arrey.Remove("Pesho");
     arrey.InsertAt(1, "Pesho");
     arrey.Clear();
     Console.WriteLine(arrey.Capacity);
     Console.WriteLine(arrey.Count);
     arrey.Add("Ivo");
     arrey[0] = "Gosho";
     var newArrey = arrey.ToArray();
     Console.WriteLine();
     foreach (var item in arrey)
     {
         Console.WriteLine(item);
     }
     Console.WriteLine();
     foreach (var item in newArrey)
     {
         Console.WriteLine(item);
     }
 }
开发者ID:iMitaka,项目名称:HackBulgaria,代码行数:27,代码来源:ProgramMain.cs

示例3: GetWalkableCellNeighbours

        private void GetWalkableCellNeighbours(Cell cell, DynamicArray<Cell> walkableCells, bool preventDiagonals)
        {
            if (walkableCells.count != 0)
            {
                // if the list for holding the cells is not empty, make it empty
                walkableCells.Clear();
            }

            int mx = cell.matrixPosX;
            int mz = cell.matrixPosZ;

            // prepare non-diagonal neighbours in all 4 directions (up, down, left, right)
            var n1 = _grid.cellMatrix[mx - 1, mz];
            var n2 = _grid.cellMatrix[mx, mz - 1];
            var n3 = _grid.cellMatrix[mx + 1, mz];
            var n4 = _grid.cellMatrix[mx, mz + 1];

            var unitAttributes = _unitProperties.attributes;

            bool lw = false, rw = false, uw = false, dw = false;

            if (n1 != null)
            {
                // check whether this neighbour has been fast marched
                lw = _fastMarchedCellsSet.ContainsKey(n1.position);
                if (!lw)
                {
                    // if the cell has not been fast marched...
                    if (n1.isWalkable(unitAttributes) && cell.isWalkableFrom(n1, _unitProperties))
                    {
                        // ... and the cell is walkable, then add it to the list
                        walkableCells.Add(n1);
                        lw = true;
                    }
                }
            }

            if (n2 != null)
            {
                dw = _fastMarchedCellsSet.ContainsKey(n2.position);
                if (!dw)
                {
                    if (n2.isWalkable(unitAttributes) && cell.isWalkableFrom(n2, _unitProperties))
                    {
                        walkableCells.Add(n2);
                        dw = true;
                    }
                }
            }

            if (n3 != null)
            {
                rw = _fastMarchedCellsSet.ContainsKey(n3.position);
                if (!rw)
                {
                    if (n3.isWalkable(unitAttributes) && cell.isWalkableFrom(n3, _unitProperties))
                    {
                        walkableCells.Add(n3);
                        rw = true;
                    }
                }
            }

            if (n4 != null)
            {
                uw = _fastMarchedCellsSet.ContainsKey(n4.position);
                if (!uw)
                {
                    if (n4.isWalkable(unitAttributes) && cell.isWalkableFrom(n4, _unitProperties))
                    {
                        walkableCells.Add(n4);
                        uw = true;
                    }
                }
            }

            if (preventDiagonals)
            {
                return;
            }

            bool urw, drw, dlw, ulw;
            if (_allowCornerCutting)
            {
                // if we allow corner cuttting, then just one of the neighbours need to be free to go diagonally
                urw = uw || rw;
                drw = dw || rw;
                dlw = dw || lw;
                ulw = uw || lw;
            }
            else
            {
                // however, if we don't allow corner cutting, then both neighbours need to be free to allow diagonal neighbour
                urw = uw && rw;
                drw = dw && rw;
                dlw = dw && lw;
                ulw = uw && lw;
            }

            if (dlw)
//.........这里部分代码省略.........
开发者ID:andrewstarnes,项目名称:wwtd2,代码行数:101,代码来源:ProgressiveVectorField.cs

示例4: GetCellNeighboursAndUnwalkability

        private bool GetCellNeighboursAndUnwalkability(Cell cell, DynamicArray<Cell> walkableCells, bool preventDiagonals)
        {
            if (walkableCells.count != 0)
            {
                // if the list for holding the cells is not empty, make it empty
                walkableCells.Clear();
            }

            var unitAttributes = _unitProperties.attributes;

            int mx = cell.matrixPosX;
            int mz = cell.matrixPosZ;

            for (int x = -1; x <= 1; x++)
            {
                for (int z = -1; z <= 1; z++)
                {
                    if (x == 0 && z == 0)
                    {
                        // cell in the middle is the cell which neighbours we want, thus ignore the center cell
                        continue;
                    }

                    if (x != 0 && z != 0 && preventDiagonals)
                    {
                        // if we are supposed to prevent diagonal moves, then ignore diagonal cell neighbours
                        continue;
                    }

                    var neighbour = _grid.cellMatrix[mx + x, mz + z];
                    if (neighbour != null)
                    {
                        if (neighbour.isWalkable(unitAttributes) && cell.isWalkableFrom(neighbour, _unitProperties))
                        {
                            // if the neighbour is walkable, and the center cell is walkable from this neighbour, then it is of interest
                            walkableCells.Add(neighbour);
                        }
                        else
                        {
                            // if we find just a single neighbour that is blocked, then we return false
                            return false;
                        }
                    }
                    else if (_builtInContainment)
                    {
                        // if there is a missing cell, and we want to use built-in containment, then return false on first missing cell (off-grid)
                        return false;
                    }
                }
            }

            return true;
        }
开发者ID:andrewstarnes,项目名称:wwtd2,代码行数:53,代码来源:ProgressiveVectorField.cs


注:本文中的DynamicArray.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。