本文整理汇总了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));
}
示例2: AddTest
public void AddTest()
{
DynamicArray<int> Arr = new DynamicArray<int>();
Arr.Add(23);
Assert.AreEqual(Arr.Length, 1);
Assert.AreEqual(Arr[0], 23);
}
示例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);
}
}
示例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];
}
}
示例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);
}
示例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);
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例13: HeightQuadTree
private HeightQuadTree(MatrixBounds bounds, int depth, int maxDepth)
{
_bounds = bounds;
_depth = depth;
_maxDepth = maxDepth;
_indexes = new DynamicArray<VectorXZ>(10);
}
示例14: AddPaymentOption
public void AddPaymentOption(PaymentOption option)
{
if (option != null)
{
DynamicArray<PaymentOption> dynamicArray = new DynamicArray<PaymentOption>();
PaymentOptions = dynamicArray.AddToArray(PaymentOptions, option);
}
}
示例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));
}