Unity queue usage summary

new queue

new a queue of type int
Queue<int> queue=new Queue<int> ();

methods and attributes

  1. Attribute Count, get the number of elements contained in Queue.
    if(queue.Count==0)
  2. Remove all elements from the Queue
    queue.Clear();
  3. Determine whether an element is in the queue
    queue.Contains( 5);
  4. Remove and return the object at the head of the Queue
    int number=queue.Dequeue()
  5. Add an object to the end of the Queue
    queue.Enqueue( 5 );
  6. Copy Queue to a new array
    public virtual object[] ToArray();
  7. Set the capacity to the actual number of elements in the Queue
    queue.TrimToSize();

Guess you like

Origin blog.csdn.net/qq_43666766/article/details/104461897