本文整理汇总了C#中System.Collections.Queue类的典型用法代码示例。如果您正苦于以下问题:C# Queue类的具体用法?C# Queue怎么用?C# Queue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Queue类属于System.Collections命名空间,在下文中一共展示了Queue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: NextFigure
//конструктор
public NextFigure(INextFigure figure)
{
this.figure = figure;
queue = new Queue<int>();
rand = new Random();
queue.Enqueue(rand.Next(0,7));
}
示例2: Run
static void Run (Queue q)
{
MergeContext context = GetDefaultContext ();
while (q.Count > 0) {
string token = (string) q.Dequeue ();
if (token.Length < 2)
Usage ();
if (token [0] == '-' && token [1] == '-') {
if (token.Length < 3)
Usage ();
switch (token [2]) {
case 'v':
Version ();
break;
case 'a':
About ();
break;
default:
Usage ();
break;
}
}
if (token [0] == '-' || token [0] == '/') {
token = token.Substring (1);
if (token == "o" || token == "out")
context.OutputPath = (string) q.Dequeue ();
else if (token == "e" || token == "exe")
context.OutputIsExecutable = true;
else if (token == "d" || token == "dll")
context.OutputIsExecutable = false;
else if (token == "L")
context.NativeLibraries.LibrariesSearchPaths.Add ((string) q.Dequeue ());
else if (token == "l")
context.NativeLibraries.Libraries.Add ((string) q.Dequeue ());
else
Usage ();
} else {
context.Assemblies.Add (token);
while (q.Count > 0)
context.Assemblies.Add ((string) q.Dequeue ());
}
}
if (context.Assemblies.Count < 2)
Error ("At least two assemblies needed");
if (context.OutputPath == "")
Error ("Please set output filename");
context.NativeLibraries.Libraries.Add ("c");
context.NativeLibraries.LibrariesSearchPaths.Add ("/lib");
context.NativeLibraries.Initialize ();
context.Link ();
}
示例3: Build
public void Build(object parentObject, Queue<SqlCommand> insertCommands, Queue<SqlCommand> insertLastCommands)
{
this.m_InsertSubclassOnly = false;
Type objectType = parentObject.GetType();
this.ProcessObjectForInsert(parentObject, objectType, insertCommands, insertLastCommands);
this.HandlePersistentChildCollections(parentObject, objectType, insertCommands, insertLastCommands);
}
示例4: WebConnectionGroup
public WebConnectionGroup (ServicePoint sPoint, string name)
{
this.sPoint = sPoint;
this.name = name;
connections = new ArrayList (1);
queue = new Queue ();
}
示例5: Listener
public Listener(IPEndPoint ipep)
{
m_Accepted = new Queue<Socket>();
m_AcceptedSyncRoot = ((ICollection)m_Accepted).SyncRoot;
m_Listener = Bind(ipep);
if (m_Listener == null)
{
return;
}
DisplayListener();
#if NewAsyncSockets
m_EventArgs = new SocketAsyncEventArgs();
m_EventArgs.Completed += new EventHandler<SocketAsyncEventArgs>( Accept_Completion );
Accept_Start();
#else
m_OnAccept = OnAccept;
try
{
IAsyncResult res = m_Listener.BeginAccept(m_OnAccept, m_Listener);
}
catch (SocketException ex)
{
NetState.TraceException(ex);
}
catch (ObjectDisposedException)
{ }
#endif
}
示例6: reset
/// <summary>
/// Call to reset from a previous run of the spider
/// </summary>
public void reset()
{
m_already = new Hashtable();
//?从本地导入索引文件
m_workload = new Queue();
m_quit = false;
}
示例7: ReversePolishNotationEvaluator
public ReversePolishNotationEvaluator()
{
output = new Queue();
ops = new Stack();
postfixExpression = string.Empty;
}
示例8: WebConnectionGroup
public WebConnectionGroup (ServicePoint sPoint, string name)
{
this.sPoint = sPoint;
this.name = name;
connections = new LinkedList<ConnectionState> ();
queue = new Queue<HttpWebRequest> ();
}
示例9: PriorityQueue
public PriorityQueue()
{
for(int i = 0; i < _queues.Length; ++i)
{
_queues[i] = new Queue();
}
}
示例10: BulletPool
public BulletPool()
{
if(this.Capacity.Equals(null))
this.Capacity = 32;
this.queue = new Queue(Capacity);
}
示例11: Player
public Player(TcpClient client, string ip, byte id)
{
try
{
this.username = "player";
this.plyClient = client;
this.x = 0;
this.y = 0;
this.z = 0;
this.rotx = 0;
this.roty = 0;
this.prefix = "";
this.id = id;
this.ip = ip;
this.world = null;
this.outQueue = new Queue<Packet>();
this.blockQueue = new Queue<Packet>();
this.IOThread = new Thread(PlayerIO);
this.outputWriter = new BinaryWriter(client.GetStream());
this.inputReader = new BinaryReader(client.GetStream());
this.IOThread.IsBackground = true;
this.IOThread.Start();
}
catch
{
}
}
示例12: DrawSnakeElement
private static void DrawSnakeElement(Queue<Position> inputQueue)
{
foreach (Position curentElementPosition in inputQueue)
{
DrawSingleElement(curentElementPosition, "*");
}
}
示例13: StartSniffing
public bool StartSniffing(LivePcapDevice deviceToSniff)
{
try
{
device = deviceToSniff;
// Open the device for capturing
int readTimeoutMilliseconds = 1000;
//device.StopCaptureTimeout = new TimeSpan(0, 1, 0);
device.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds);
device.SetFilter(GetFilterExpression());
packetQueue = new Queue();
sniffingThread = new Thread(new ThreadStart(SnifferLoop));
sniffingThread.Name = "Sniffing Thread";
sniffingThread.IsBackground = true;
sniffingThread.Start();
decodingThread = new Thread(new ThreadStart(DecoderLoop));
decodingThread.Name = "Decoding Thread";
decodingThread.IsBackground = true;
decodingThread.Start();
Log("Sniffing started");
}
catch (Exception e)
{
Log(e.ToString());
return false;
}
return true;
}
示例14: getTypes
private static IEnumerable<Type> getTypes(Type sourceType)
{
Queue<Type> pending = new Queue<Type>();
HashSet<Type> visited = new HashSet<Type>();
pending.Enqueue(sourceType);
while (pending.Count != 0)
{
Type type = pending.Dequeue();
visited.Add(type);
yield return type;
if (type.BaseType != null)
{
if (!visited.Contains(type.BaseType))
{
pending.Enqueue(type.BaseType);
}
}
foreach (Type interfaceType in type.GetInterfaces())
{
if (!visited.Contains(interfaceType))
{
pending.Enqueue(interfaceType);
}
}
}
}
示例15: Start
public IEnumerator Start()
{
pool = new InventoryPool<InventoryUIItemWrapper>(wrapperPrefab, 8);
queue = new Queue<ItemHolder>(8);
destroyTimer = new WaitForSeconds(slideAnimation.length - 0.025f);
offsetTimer = new WaitForSeconds(offsetTimerSeconds);
foreach (var inv in InventoryManager.GetLootToCollections())
{
inv.OnAddedItem += (items, amount, cameFromCollection) =>
{
if (cameFromCollection == false)
{
queue.Enqueue(new ItemHolder() { item = items.FirstOrDefault(), stackSize = amount});
}
};
}
while (true)
{
if (queue.Count > 0)
{
ShowItem(queue.Peek().item, queue.Peek().stackSize);
queue.Dequeue(); // Remove it
}
yield return offsetTimer;
}
}