ConcurrentStack<T>.TryPopRange 方法

定義

多載

TryPopRange(T[], Int32, Int32)

嘗試從 ConcurrentStack<T> 頂端以不可分割方式快顯並傳回多個物件。

TryPopRange(T[])

嘗試從 ConcurrentStack<T> 頂端以不可分割方式快顯並傳回多個物件。

TryPopRange(T[], Int32, Int32)

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

嘗試從 ConcurrentStack<T> 頂端以不可分割方式快顯並傳回多個物件。

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

參數

items
T[]

Array,將在其中加入從 ConcurrentStack<T> 頂端位置快顯的物件。

startIndex
Int32

items 中以零為起始的位移,從此處開始將項目插入 ConcurrentStack<T> 頂端。

count
Int32

要從 ConcurrentStack<T> 頂端快顯,並插入 items 中的項目數目。

傳回

從堆疊頂端位置順利快顯並插入 items 中的物件數目。

例外狀況

items 是 null 參考 (在 Visual Basic 中為 Nothing)。

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

startIndex + count 大於 items 的長度。

備註

在彈出多個專案時,如果堆疊上沒有爭用,使用 TryPopRange 可能會比移除每個專案使用 TryPop 一次更有效率。 節點會在 startIndex 中填入要彈出的第一個專案、在 startIndex + 1 中彈出的第二個專案,以此類傳來填入 items 數位。

另請參閱

適用於

TryPopRange(T[])

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

嘗試從 ConcurrentStack<T> 頂端以不可分割方式快顯並傳回多個物件。

public:
 int TryPopRange(cli::array <T> ^ items);
public int TryPopRange (T[] items);
member this.TryPopRange : 'T[] -> int
Public Function TryPopRange (items As T()) As Integer

參數

items
T[]

Array,將在其中加入從 ConcurrentStack<T> 頂端位置快顯的物件。

傳回

ConcurrentStack<T> 頂端位置快顯,並且插入 items 中的物件數目。

例外狀況

items 是 null 引數 (在 Visual Basic 中為 Nothing)。

備註

快顯多個專案時,如果堆疊上沒有爭用,使用 TryPopRange 可能會比每個項目移除一 TryPop 次更有效率。 節點會在 startIndex 中填入要彈出的第一個專案、在 startIndex + 1 中彈出的第二個專案,以此類傳來填入 items 數位。

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

另請參閱

適用於