Uređivanje

Dijeli putem


ConcurrentStack<T>.TryPopRange Method

Definition

Overloads

TryPopRange(T[], Int32, Int32)

Attempts to pop and return multiple objects from the top of the ConcurrentStack<T> atomically.

TryPopRange(T[])

Attempts to pop and return multiple objects from the top of the ConcurrentStack<T> atomically.

TryPopRange(T[], Int32, Int32)

Source:
ConcurrentStack.cs
Source:
ConcurrentStack.cs
Source:
ConcurrentStack.cs

Attempts to pop and return multiple objects from the top of the ConcurrentStack<T> atomically.

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

Parameters

items
T[]

The Array to which objects popped from the top of the ConcurrentStack<T> will be added.

startIndex
Int32

The zero-based offset in items at which to begin inserting elements from the top of the ConcurrentStack<T>.

count
Int32

The number of elements to be popped from top of the ConcurrentStack<T> and inserted into items.

Returns

The number of objects successfully popped from the top of the stack and inserted in items.

Exceptions

items is a null reference (Nothing in Visual Basic).

startIndex or count is negative. Or startIndex is greater than or equal to the length of items.

startIndex + count is greater than the length of items.

Remarks

When popping multiple items, if there is little contention on the stack, using TryPopRange can be more efficient than using TryPop once per item to be removed. Nodes fill the items array with the first item to be popped at the startIndex, the second item to be popped at startIndex + 1, and so on.

See also

Applies to

TryPopRange(T[])

Source:
ConcurrentStack.cs
Source:
ConcurrentStack.cs
Source:
ConcurrentStack.cs

Attempts to pop and return multiple objects from the top of the ConcurrentStack<T> atomically.

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

Parameters

items
T[]

The Array to which objects popped from the top of the ConcurrentStack<T> will be added.

Returns

The number of objects successfully popped from the top of the ConcurrentStack<T> and inserted in items.

Exceptions

items is a null argument (Nothing in Visual Basic).

Remarks

When popping multiple items, if there is little contention on the stack, using TryPopRange can be more efficient than using TryPop once per item to be removed. Nodes fill the items array with the first item to be popped at the startIndex, the second item to be popped at startIndex + 1, and so on.

For a code example, see ConcurrentStack<T>.

See also

Applies to