ConcurrentStack<T>.PushRange 方法

定义

重载

PushRange(T[])

自动将多个对象插入 ConcurrentStack<T> 的顶部。Inserts multiple objects at the top of the ConcurrentStack<T> atomically.

PushRange(T[], Int32, Int32)

自动将多个对象插入 ConcurrentStack<T> 的顶部。Inserts multiple objects at the top of the ConcurrentStack<T> atomically.

PushRange(T[])

自动将多个对象插入 ConcurrentStack<T> 的顶部。Inserts multiple objects at the top of the ConcurrentStack<T> atomically.

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> 中的对象。The objects to push onto the ConcurrentStack<T>.

异常

items 为 null 引用(在 Visual Basic 中为 Nothing)。items is a null reference (Nothing in Visual Basic).

注解

在将多个项添加到堆栈时,使用 PushRange 是一种比同时使用一项 Push 更为有效的机制。When adding multiple items to the stack, using PushRange is a more efficient mechanism than using Push one item at a time. 此外,PushRange 保证将以原子方式添加所有元素,这意味着任何其他线程都不能在所推送的元素之间注入元素。Additionally, PushRange guarantees that all of the elements will be added atomically, meaning that no other threads will be able to inject elements between the elements being pushed. 位于 items 数组中较低索引处的项将被推送到较高索引处的项之前。Items at lower indices in the items array will be pushed before items at higher indices.

有关代码示例,请参阅ConcurrentStack<T>For a code example, see ConcurrentStack<T>.

另请参阅

PushRange(T[], Int32, Int32)

自动将多个对象插入 ConcurrentStack<T> 的顶部。Inserts multiple objects at the top of the ConcurrentStack<T> atomically.

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> 中的对象。The objects to push onto the ConcurrentStack<T>.

startIndex
Int32

items 中从零开始的偏移量,在此开始将元素插入到 ConcurrentStack<T> 的顶部。The zero-based offset in items at which to begin inserting elements onto the top of the ConcurrentStack<T>.

count
Int32

要插入到 ConcurrentStack<T> 的顶部的元素数。The number of elements to be inserted onto the top of the ConcurrentStack<T>.

异常

items 为 null 引用(在 Visual Basic 中为 Nothing)。items is a null reference (Nothing in Visual Basic).

startIndexcount 为负数。startIndex or count is negative. startIndex 大于或等于 items 的长度。Or startIndex is greater than or equal to the length of items.

startIndex + count 大于 items 的长度。startIndex + count is greater than the length of items.

注解

在将多个项添加到堆栈时,使用 PushRange 是一种比同时使用一项 Push 更为有效的机制。When adding multiple items to the stack, using PushRange is a more efficient mechanism than using Push one item at a time. 此外,PushRange 保证将以原子方式添加所有元素,这意味着任何其他线程都不能在所推送的元素之间注入元素。Additionally, PushRange guarantees that all of the elements will be added atomically, meaning that no other threads will be able to inject elements between the elements being pushed. 位于 items 数组中较低索引处的项将被推送到较高索引处的项之前。Items at lower indices in the items array will be pushed before items at higher indices.

有关代码示例,请参阅ConcurrentStack<T>For a code example, see ConcurrentStack<T>.

另请参阅

适用于