Пример #1
0
        public void TestQueue()
        {
            var queue = new IndexedQueue <int>(new int[] { 1, 2, 3 });

            queue.Count.Should().Be(3);

            queue.Enqueue(4);
            queue.Count.Should().Be(4);
            queue.Peek().Should().Be(1);
            queue.TryPeek(out var a).Should().BeTrue();
            a.Should().Be(1);

            queue[0].Should().Be(1);
            queue[1].Should().Be(2);
            queue[2].Should().Be(3);
            queue.Dequeue().Should().Be(1);
            queue.Dequeue().Should().Be(2);
            queue.Dequeue().Should().Be(3);
            queue[0] = 5;
            queue.TryDequeue(out a).Should().BeTrue();
            a.Should().Be(5);

            queue.Enqueue(4);
            queue.Clear();
            queue.Count.Should().Be(0);
        }
Пример #2
0
    private void Awake()
    {
        _collider = GetComponent <Collider2D>();

        for (int i = 0; i < StartingTailCnt; ++i)
        {
            _tailPieces.Add(GameObject.Instantiate(TailPrefab, transform.position, Quaternion.identity));
        }

        _recordPosTimer = RecordFreuency;

        int queueMaxSize = GetQueueMaxSize();

        for (int i = 0; i < queueMaxSize; ++i)
        {
            _positionQueue.Enqueue(transform.position.ToVec2XY());
        }
    }
Пример #3
0
 /** Add a work item to be processed when pathfinding is paused.
  *
  * \see ProcessWorkItems
  */
 public void AddWorkItem(AstarWorkItem itm)
 {
     workItems.Enqueue(itm);
 }