ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

EnqueueRange

Enqueues a generic collection of items

Source

public static void EnqueueRange<T>(this Queue<T> queue, IEnumerable<T> collection) 
{
	foreach (T item in collection)
		queue.Enqueue(item);
}

Example

var queue = new Queue<string>();
var list = new List<string>() { "aaa", "bbb" };
queue.EnqueueRange(list);

Author: David Seff

Submitted on: 19 jul. 2016

Language: C#

Type: void

Views: 3808