ConcurrentStack<T>.PushRange 方法

定義

多載

PushRange(T[])

將多個物件以不可分割方式插入 ConcurrentStack<T> 的頂端。

PushRange(T[], Int32, Int32)

將多個物件以不可分割方式插入 ConcurrentStack<T> 的頂端。

PushRange(T[])

來源:
ConcurrentStack.cs
來源:
ConcurrentStack.cs
來源:
ConcurrentStack.cs

將多個物件以不可分割方式插入 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 是 null 參考 (在 Visual Basic 中為 Nothing)。

備註

將多個專案新增至堆疊時,使用 PushRange 是比一次使用 Push 一個專案更有效率的機制。 此外,PushRange 保證所有元素都會以不可部分完成的方式新增,這表示沒有其他線程能夠在所推送的項目之間插入元素。 陣列中 items 索引較低的專案會在較高索引的專案之前推送。

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

另請參閱

適用於

PushRange(T[], Int32, Int32)

來源:
ConcurrentStack.cs
來源:
ConcurrentStack.cs
來源:
ConcurrentStack.cs

將多個物件以不可分割方式插入 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 是 null 參考 (在 Visual Basic 中為 Nothing)。

startIndexcount 為負。 或 startIndex 大於或等於 items 的長度。

startIndex + count 大於 items 的長度。

備註

將多個專案新增至堆疊時,使用 PushRange 是比一次使用 Push 一個專案更有效率的機制。 此外,PushRange 保證所有元素都會以不可部分完成的方式新增,這表示沒有其他線程能夠在所推送的項目之間插入元素。 陣列中 items 索引較低的專案會在較高索引的專案之前推送。

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

另請參閱

適用於