1 using System;
 2  using System.Collections;
 3  public class SamplesQueue  {
 4  
 5     public static void Main()  {
 6  
 7        // Creates and initializes a new Queue.
 8        Queue myQ = new Queue();
 9        myQ.Enqueue("Hello");
10        myQ.Enqueue("World");
11        myQ.Enqueue("!");
12  
13        // Displays the properties and values of the Queue.
14        Console.WriteLine( "myQ" );
15        Console.WriteLine( "\tCount:    {0}", myQ.Count );
16        Console.Write( "\tValues:" );
17        PrintValues( myQ );
18     }
19  
20  
21     public static void PrintValues( IEnumerable myCollection )  {
22        foreach ( Object obj in myCollection )
23           Console.Write( "    {0}", obj );
24        Console.WriteLine();
25     }
26  }
27  /* 
28  This code produces the following output.
29  
30  myQ
31      Count:    3
32      Values:    Hello    World    !
33 */

 

构造函数 

Queue()

Queue 类的新实例,该实例为空,具有默认初始容量并使用默认增长因子。

Queue(ICollection)

Queue 类的新实例,该实例包含从指定集合复制的元素,具有与所复制的元素数相同的初始容量并使用默认增长因子。

Queue(Int32)

Queue 类的新实例,该实例为空,具有指定的初始容量并使用默认增长因子。

Queue(Int32, Single)

Queue 类的新实例,该实例为空,具有指定的初始容量并使用指定的增长因子。

属性 

Count

Queue 中包含的元素数。

IsSynchronized

Queue 的访问(线程安全)。

SyncRoot

Queue 的访问的对象。

方法 

Clear()

Queue 中移除所有对象。

Clone()

Queue 的浅表副本。

Contains(Object)

Queue 中。

CopyTo(Array, Int32)

Array 中。

Dequeue()

Queue 开始处的对象。

Enqueue(Object)

Queue 的结尾处。

Equals(Object)

确定指定的对象是否等于当前对象。

(Inherited from Object)
GetEnumerator()

Queue 的枚举数。

GetHashCode()

作为默认哈希函数。

(Inherited from Object)
GetType()

Type。

(Inherited from Object)
MemberwiseClone()

Object 的浅表副本。

(Inherited from Object)
Peek()

Queue 开始处的对象但不将其移除。

Synchronized(Queue)

Queue,它将包装原始队列,并且是线程安全的。

ToArray()

Queue 元素复制到新数组。

ToString()

返回表示当前对象的字符串。

(Inherited from Object)
TrimToSize()

Queue 中元素的实际数目。

 

相关文章:

  • 2022-12-23
  • 2021-10-03
  • 2021-08-16
  • 2021-08-02
  • 2022-12-23
  • 2022-01-19
  • 2021-04-30
  • 2021-06-26
猜你喜欢
  • 2022-12-23
  • 2021-07-24
  • 2021-08-15
  • 2021-07-27
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案