Using the occasion
If the first object is a first object is stored to be used, it is necessary to use Queue (queue), for example:
沿着单向街道行进的车流
排队的人
不挂机等候客户支持热线服务的客户
所有按先来先服务原则处理的情况
Compared Queue List and characteristics
不能按任意索引增加或删除项
增加对象时要入队(enqueue)
删除对象时,将第一个对象出队(dequeue)
Queue class of some common attributes:
Attributes | description |
---|---|
Count | Get the number of elements contained in the Queue. |
Some commonly used methods Queue class:
- public virtual void Clear (); removing all the elements from the Queue.
- public virtual bool Contains (object obj); determining whether an element in the Queue.
- public virtual object Dequeue () Removes and returns the object at the beginning of the Queue.
- public virtual void Enqueue (object obj); add an object to the end of the Queue.
- public virtual object [] ToArray (); Queue copied into a new array.
- public virtual void TrimToSize (); set a capacity of the actual number of elements in the Queue.