ConcurrentStack<T>.PushRange 方法

定义

重载

名称 说明
PushRange(T[])

以原子方式插入多个对象 ConcurrentStack<T>

PushRange(T[], Int32, Int32)

以原子方式插入多个对象 ConcurrentStack<T>

PushRange(T[])

以原子方式插入多个对象 ConcurrentStack<T>

public:
 void PushRange(cli::array <T> ^ items);
public void PushRange(T[] items);
member this.PushRange : 'T[] -> unit
Public Sub PushRange (items As T())

参数

items
T[]

要推送到 .ConcurrentStack<T>

例外

items 是空引用(Visual Basic 中没有任何内容)。

注解

将多个项添加到堆栈时,使用 PushRange 是一种比一次使用 Push 一个项更高效的机制。 此外,PushRange 保证以原子方式添加所有元素,这意味着其他线程将无法在推送的元素之间注入元素。 数组中 items 索引较低的项将推送到索引较高的项之前。

有关代码示例,请参阅 ConcurrentStack<T>

另请参阅

适用于

PushRange(T[], Int32, Int32)

以原子方式插入多个对象 ConcurrentStack<T>

public:
 void PushRange(cli::array <T> ^ items, int startIndex, int count);
public void PushRange(T[] items, int startIndex, int count);
member this.PushRange : 'T[] * int * int -> unit
Public Sub PushRange (items As T(), startIndex As Integer, count As Integer)

参数

items
T[]

要推送到 .ConcurrentStack<T>

startIndex
Int32

从零开始的偏移 items 量,开始将元素插入到顶部 ConcurrentStack<T>

count
Int32

要插入到顶部的 ConcurrentStack<T>元素数。

例外

items 是空引用(Visual Basic 中没有任何内容)。

startIndexcount 为负数。 或者 startIndex 大于或等于长度 items

startIndex + count 大于长度 items

注解

将多个项添加到堆栈时,使用 PushRange 是一种比一次使用 Push 一个项更高效的机制。 此外,PushRange 保证以原子方式添加所有元素,这意味着其他线程将无法在推送的元素之间注入元素。 数组中 items 索引较低的项将推送到索引较高的项之前。

有关代码示例,请参阅 ConcurrentStack<T>

另请参阅

适用于