CKTIS / C#
System.Collections.Generic.Queue: praktická reference
System.Collections.Generic.Queue: praktická reference: Queue<T> implementuje pořadí první dovnitř, první ven pomocí Enqueue, Peek a Dequeue.
Verze: .NET API; verified on .NET 10.0.14
Syntaxe
System.Collections.Generic.Queue /* select a documented member or constructor */Queue implementuje pořadí první dovnitř, první ven pomocí Enqueue, Peek a Dequeue.
Použijte ji pro pracovní fronty a prohledávání do šířky v jednom vlákně nebo s externí synchronizací.
Není bezpečná pro souběžné zápisy; při změnách více vlákny zvolte ConcurrentQueue.
Dequeue a Peek na prázdné frontě vyvolají InvalidOperationException, zatímco TryDequeue a TryPeek vrátí false.
Úplný program skutečně používá System.Collections.Generic.Queue; přesně očekávaný stdout je 1.
Příklady
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
var queue = new Queue<int>();
queue.Enqueue(1); queue.Enqueue(2);
Console.WriteLine(queue.Dequeue());
Výsledek
1
Úplný program skutečně používá `System.Collections.Generic.Queue`; přesně očekávaný stdout je `1`.