添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
generic <typename T>
public ref class ConcurrentQueue : System::Collections::Concurrent::IProducerConsumerCollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IReadOnlyCollection<T>, System::Collections::ICollection
generic <typename T>
public ref class ConcurrentQueue : System::Collections::Concurrent::IProducerConsumerCollection<T>, System::Collections::Generic::IEnumerable<T>
generic <typename T>
public ref class ConcurrentQueue : System::Collections::Concurrent::IProducerConsumerCollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::Generic::IReadOnlyCollection<T>
generic <typename T>
public ref class ConcurrentQueue : System::Collections::Concurrent::IProducerConsumerCollection<T>, System::Collections::Generic::IEnumerable<T>, System::Collections::ICollection
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>, System.Collections.ICollection
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.ICollection
public class ConcurrentQueue<T> : System.Collections.Concurrent.IProducerConsumerCollection<T>, System.Collections.Generic.IEnumerable<T>, System.Collections.Generic.IReadOnlyCollection<T>
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface seq<'T>
    interface IEnumerable
    interface ICollection
    interface IReadOnlyCollection<'T>
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface seq<'T>
    interface ICollection
    interface IEnumerable
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface seq<'T>
    interface IEnumerable
    interface ICollection
    interface IReadOnlyCollection<'T>
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface seq<'T>
    interface ICollection
    interface IEnumerable
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type ConcurrentQueue<'T> = class
    interface IProducerConsumerCollection<'T>
    interface IReadOnlyCollection<'T>
    interface seq<'T>
    interface ICollection
    interface IEnumerable
Public Class ConcurrentQueue(Of T)
Implements ICollection, IEnumerable(Of T), IProducerConsumerCollection(Of T), IReadOnlyCollection(Of T)
Public Class ConcurrentQueue(Of T)
Implements IEnumerable(Of T), IProducerConsumerCollection(Of T)
Public Class ConcurrentQueue(Of T)
Implements IEnumerable(Of T), IProducerConsumerCollection(Of T), IReadOnlyCollection(Of T)
Public Class ConcurrentQueue(Of T)
Implements ICollection, IEnumerable(Of T), IProducerConsumerCollection(Of T)
// ConcurrentQueue<T>.Enqueue() // ConcurrentQueue<T>.TryPeek() // ConcurrentQueue<T>.TryDequeue() static void Main () // Construct a ConcurrentQueue. ConcurrentQueue<int> cq = new ConcurrentQueue<int>(); // Populate the queue. for (int i = 0; i < 10000; i++) cq.Enqueue(i); // Peek at the first element. int result; if (!cq.TryPeek(out result)) Console.WriteLine("CQ: TryPeek failed when it should have succeeded"); else if (result != 0) Console.WriteLine("CQ: Expected TryPeek result of 0, got {0}", result); int outerSum = 0; // An action to consume the ConcurrentQueue. Action action = () => int localSum = 0; int localValue; while (cq.TryDequeue(out localValue)) localSum += localValue; Interlocked.Add(ref outerSum, localSum); // Start 4 concurrent consuming actions. Parallel.Invoke(action, action, action, action); Console.WriteLine("outerSum = {0}, should be 49995000", outerSum); open System open System.Collections.Concurrent open System.Threading open System.Threading.Tasks // Demonstrates: // ConcurrentQueue<T>.Enqueue() // ConcurrentQueue<T>.TryPeek() // ConcurrentQueue<T>.TryDequeue() // Construct a ConcurrentQueue. let cq = ConcurrentQueue<int>() // Populate the queue. for i = 0 to 9999 do cq.Enqueue i // Peek at the first element. let mutable result = 0 if cq.TryPeek &result |> not then printfn "CQ: TryPeek failed when it should have succeeded" elif result <> 0 then printfn $"CQ: Expected TryPeek result of 0, got {result}" let mutable outerSum = 0 // An action to consume the ConcurrentQueue. let action = Action(fun () -> let mutable localSum = 0 let mutable localValue = 0 while cq.TryDequeue &localValue do localSum <- localSum + localValue Interlocked.Add(&outerSum, localSum) |> ignore) // Start 4 concurrent consuming actions. Parallel.Invoke(action, action, action, action) printfn $"outerSum = {outerSum}, should be 49995000" Imports System.Collections.Concurrent Imports System.Threading Imports System.Threading.Tasks Class TestQueue ' Demonstrates: ' ConcurrentQueue<T>.Enqueue() ' ConcurrentQueue<T>.TryPeek() ' ConcurrentQueue<T>.TryDequeue() Shared Sub Main() ' Construct a ConcurrentQueue Dim cq As New ConcurrentQueue(Of Integer)() ' Populate the queue For i As Integer = 0 To 9999 cq.Enqueue(i) ' Peek at the first element Dim result As Integer If Not cq.TryPeek(result) Then Console.WriteLine("CQ: TryPeek failed when it should have succeeded") ElseIf result <> 0 Then Console.WriteLine("CQ: Expected TryPeek result of 0, got {0}", result) End If Dim outerSum As Integer = 0 ' An action to consume the ConcurrentQueue Dim action As Action = Sub() Dim localSum As Integer = 0 Dim localValue As Integer While cq.TryDequeue(localValue) localSum += localValue End While Interlocked.Add(outerSum, localSum) End Sub ' Start 4 concurrent consuming actions Parallel.Invoke(action, action, action, action) Console.WriteLine("outerSum = {0}, should be 49995000", outerSum) End Sub End Class

ConcurrentQueue<T> IReadOnlyCollection<T> 实现从 .NET Framework 4.6 开始的接口;在.NET Framework的早期版本中, ConcurrentQueue<T> 类未实现此接口。

ToImmutableDictionary<TSource,TKey,TValue>(IEnumerable<TSource>, Func<TSource,TKey>, Func<TSource,TValue>, IEqualityComparer<TKey>, IEqualityComparer<TValue>)

枚举并转换序列,然后使用指定的键和值比较器生成其内容的不可变字典。

GroupBy<TSource,TKey,TElement,TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource,TElement>, Func<TKey,IEnumerable<TElement>, TResult>, IEqualityComparer<TKey>)

根据指定的键选择器函数对序列中的元素进行分组,并且从每个组及其键中创建结果值。 通过使用指定的比较器对键值进行比较,并且通过使用指定的函数对每个组的元素进行投影。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>)

基于键值等同性对两个序列的元素进行关联,并对结果进行分组。 使用默认的相等比较器对键进行比较。

GroupJoin<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,IEnumerable<TInner>, TResult>, IEqualityComparer<TKey>)

基于键值等同性对两个序列的元素进行关联,并对结果进行分组。 使用指定的 IEqualityComparer<T> 对键进行比较。

Join<TOuter,TInner,TKey,TResult>(IEnumerable<TOuter>, IEnumerable<TInner>, Func<TOuter,TKey>, Func<TInner,TKey>, Func<TOuter,TInner,TResult>, IEqualityComparer<TKey>)

基于匹配键对两个序列的元素进行关联。 使用指定的 IEqualityComparer<T> 对键进行比较。