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


C# DynamicArray类代码示例

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


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

示例1: ToArray

 public static void ToArray()
 {
     DynamicArray<int> darray = new DynamicArray<int>(1);
     darray.Insert(Data, 0, 0);
     Assert.That(darray, Is.EqualTo((int[])darray.ToArray()));
     Assert.That(darray, Is.EqualTo((int[])darray));
 }
开发者ID:Sinbadsoft,项目名称:Sinbadsoft.Lib.Collections,代码行数:7,代码来源:ConversionTests.cs

示例2: AddTest

 public void AddTest()
 {
     DynamicArray<int> Arr = new DynamicArray<int>();
     Arr.Add(23);
     Assert.AreEqual(Arr.Length, 1);
     Assert.AreEqual(Arr[0], 23);
 }
开发者ID:PozdeyevArtyom,项目名称:megarepository,代码行数:7,代码来源:Task03Tests.cs

示例3: 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

示例4: FullGridVectorField

        /// <summary>
        /// Initializes a new instance of the <see cref="FullGridVectorField"/> class.
        /// </summary>
        /// <param name="group">The transient unit group.</param>
        /// <param name="path">The path.</param>
        /// <param name="options">The vector field options.</param>
        public FullGridVectorField(TransientGroup<IUnitFacade> group, Path path, VectorFieldOptions options)
        {
            Ensure.ArgumentNotNull(group, "group");
            this.group = group;

            _currentPath = path;

            var modelUnit = group.modelUnit;
            _unitProperties = modelUnit;
            var pathOptions = modelUnit.pathFinderOptions;

            // cache options locally
            _obstacleStrengthFactor = options.obstacleStrengthFactor;
            _allowCornerCutting = pathOptions.allowCornerCutting;
            _allowDiagonals = !pathOptions.preventDiagonalMoves;
            _announceAllNodes = modelUnit.pathNavigationOptions.announceAllNodes;

            _builtInContainment = options.builtInContainment;
            _updateInterval = options.updateInterval;

            // pre-allocate lists
            _openSet = new SimpleQueue<Cell>(31);
            _tempWalkableNeighbours = new DynamicArray<Cell>(8);
            _extraTempWalkableNeighbours = new DynamicArray<Cell>(8);

            _grid = GridManager.instance.GetGrid(group.modelUnit.position);
            if (_grid != null)
            {
                _fastMarchedCells = new PlaneVector[_grid.sizeX, _grid.sizeZ];
                _cellDirs = new VectorFieldCell[_grid.sizeX, _grid.sizeZ];
            }
        }
开发者ID:nickreynolds,项目名称:FirstPersonTowerDefense,代码行数:38,代码来源:FullGridVectorField.cs

示例5: CustomCapacityConstructorTest

 public void CustomCapacityConstructorTest()
 {
     int ActualCapacity = 5;
     DynamicArray<int> Arr = new DynamicArray<int>(ActualCapacity);
     Assert.AreEqual(Arr.Capacity, ActualCapacity);
     Assert.AreEqual(Arr.Length, 0);
 }
开发者ID:PozdeyevArtyom,项目名称:megarepository,代码行数:7,代码来源:Task03Tests.cs

示例6: GridManager

 /// <summary>
 /// Initializes a new instance of the <see cref="GridManager"/> class.
 /// </summary>
 public GridManager()
 {
     _grids = new List<IGrid>();
     _gridComponents = new List<GridComponent>();
     _portals = new DynamicArray<GridPortal>(0);
     _portalsLookup = new Dictionary<string, GridPortal>(StringComparer.Ordinal);
 }
开发者ID:forwolk,项目名称:UnityApex,代码行数:10,代码来源:GridManager.cs

示例7: RandomOperation

 public void RandomOperation()
 {
     var r = new Random();
     const int totalOperations = 10000;
     var target = new DynamicArray<int>();
     for (var i = 0; i < totalOperations; i++)
     {
         int oldCount = target.Count;
         switch (r.Next(3))
         {
             case 0: // Add
                 var newItem = r.Next();
                 target.Add(newItem);
                 Assert.AreEqual(oldCount + 1, target.Count);
                 Assert.AreEqual(newItem, target[oldCount]);
                 break;
             case  1: // Remove by index
                 if(oldCount == 0) goto case 0;
                 var indexToRemove = r.Next(oldCount - 1);
                 target.RemoveAt(indexToRemove);
                 Assert.AreEqual(oldCount - 1, target.Count);
                 break;
             case 2: // Remove by element
                 if (oldCount == 0) goto case 0;
                 var itemToRemove = target[r.Next(oldCount - 1)];
                 target.Remove(itemToRemove);
                 Assert.AreEqual(oldCount - 1, target.Count);
                 break;
         }
     }
 }
开发者ID:jbmercha,项目名称:Dast,代码行数:31,代码来源:DynamicArrayUnitTests.cs

示例8: 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

示例9: PathingAStar

 /// <summary>
 /// Initializes a new instance of the <see cref="PathingAStar"/> class.
 /// </summary>
 /// <param name="heapInitialSize">Initial size of the heap.</param>
 /// <param name="moveCostProvider">The move cost provider.</param>
 /// <param name="pathSmoother">The path smoother to use.</param>
 public PathingAStar(int heapInitialSize, IMoveCost moveCostProvider, ICellCostStrategy cellCostStrategy, ISmoothPaths pathSmoother)
     : base(moveCostProvider, cellCostStrategy, pathSmoother)
 {
     _openSet = new BinaryHeap<IPathNode>(heapInitialSize, new PathNodeComparer());
     _expandedSet = new List<IPathNode>();
     _successorArray = new DynamicArray<IPathNode>(15);
 }
开发者ID:forwolk,项目名称:UnityApex,代码行数:13,代码来源:PathingAStar.cs

示例10: TestIEnum

 public void TestIEnum()
 {
     int[] arr = new[] { 1, 2, 3, 4, 5 };
     DynamicArray<int> m3 = new DynamicArray<int>(arr);
     foreach (var elem in m3)
         Console.WriteLine(elem);
 }
开发者ID:egorbulychev127,项目名称:Repository1,代码行数:7,代码来源:TestIEnumerable.cs

示例11: ConstrOneParam

 public void ConstrOneParam()
 {
     DynamicArray<int> m2 = new DynamicArray<int>(9);
     var a = m2.Length;
     Assert.AreEqual(a, 0);
     var b = m2.Capacity;
     Assert.AreEqual(b, 9);
 }
开发者ID:egorbulychev127,项目名称:Repository1,代码行数:8,代码来源:ConstructorParameter.cs

示例12: DefConstr

 public void DefConstr()
 {
     DynamicArray<int> m1 = new DynamicArray<int>();
     var a = m1.Length;
     Assert.AreEqual(a, 0);
     var b = m1.Capacity;
     Assert.AreEqual(b, 8);
 }
开发者ID:egorbulychev127,项目名称:Repository1,代码行数:8,代码来源:DefaultConstructor.cs

示例13: HeightQuadTree

        private HeightQuadTree(MatrixBounds bounds, int depth, int maxDepth)
        {
            _bounds = bounds;
            _depth = depth;
            _maxDepth = maxDepth;

            _indexes = new DynamicArray<VectorXZ>(10);
        }
开发者ID:andrewstarnes,项目名称:wwtd2,代码行数:8,代码来源:HeightQuadTree.cs

示例14: AddPaymentOption

 public void AddPaymentOption(PaymentOption option)
 {
     if (option != null)
     {
         DynamicArray<PaymentOption> dynamicArray = new DynamicArray<PaymentOption>();
         PaymentOptions = dynamicArray.AddToArray(PaymentOptions, option);
     }
 }
开发者ID:yjddd412213,项目名称:AccountProvider,代码行数:8,代码来源:AccountInfoCatalog.Ext.cs

示例15: GenericCopyTo

 public static void GenericCopyTo()
 {
     DynamicArray<int> darray = new DynamicArray<int>(1);
     DynamicArray<int> dcopy = new DynamicArray<int>(1);
     darray.Insert(Data, 0, 0);
     darray.CopyTo(dcopy, 0);
     Assert.That(darray, Is.EqualTo(dcopy));
 }
开发者ID:Sinbadsoft,项目名称:Sinbadsoft.Lib.Collections,代码行数:8,代码来源:ConversionTests.cs


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