ConcurrentStack<T>.PushRange 方法

定義

多載

名稱 Description
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

從零點開始將元素插入到頂部ConcurrentStack<T>的偏移items量。

count
Int32

要插入 ConcurrentStack<T>到頂部的元素數量。

例外狀況

items 是空參考(Visual Basic 中無任何參考)。

startIndexcount 是陰性。 或 startIndex 大於或等於 的 items長度。

startIndex + count 大於 的 items長度。

備註

在增加多個項目到堆疊時,使用 PushRange 比一次只使用 Push 一個項目更有效率。 此外,PushRange 保證所有元素都會以原子方式加入,意味著其他執行緒無法在被推送的元素之間注入元素。 陣列中索引較低 items 的項目會先推送,優先於較高索引的項目。

如需程式碼範例,請參閱ConcurrentStack<T>

另請參閱

適用於