Bewerken

Delen via


ConcurrentStack<T>.PushRange Method

Definition

Overloads

PushRange(T[])

Inserts multiple objects at the top of the ConcurrentStack<T> atomically.

PushRange(T[], Int32, Int32)

Inserts multiple objects at the top of the ConcurrentStack<T> atomically.

PushRange(T[])

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

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())

Parameters

items
T[]

The objects to push onto the ConcurrentStack<T>.

Exceptions

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

Remarks

When adding multiple items to the stack, using PushRange is a more efficient mechanism than using Push one item at a time. 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 at lower indices in the items array will be pushed before items at higher indices.

For a code example, see ConcurrentStack<T>.

See also

Applies to

PushRange(T[], Int32, Int32)

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

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)

Parameters

items
T[]

The objects to push onto the ConcurrentStack<T>.

startIndex
Int32

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

count
Int32

The number of elements to be inserted onto the top of the ConcurrentStack<T>.

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 adding multiple items to the stack, using PushRange is a more efficient mechanism than using Push one item at a time. 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 at lower indices in the items array will be pushed before items at higher indices.

For a code example, see ConcurrentStack<T>.

See also

Applies to