Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

IQueue Interface

A collection designed for holding elements prior to processing.

For a list of all members of this type, see IQueue Members .

[Visual Basic]
Public Interface IQueue
    Implements ICollection, IEnumerable
[C#]
public interface IQueue : ICollection, IEnumerable

Types that implement IQueue

Type Description
AbstractQueue This class provides skeletal implementations of some IQueue operations.
PriorityQueue An unbounded priority IQueue based on a priority heap. This queue orders elements according to an order specified at construction time, which is specified either according to their natural order (see IComparable, or according to a IComparer, depending on which constructor is used. A priority queue does not permit elements. A priority queue relying on natural ordering also does not permit insertion of non-comparable objects (doing so will result InvalidCastException.

The head of this queue is the lowest element with respect to the specified ordering. If multiple elements are tied for lowest value, the head is one of those elements -- ties are broken arbitrarily.

A priority queue is unbounded, but has an internal capacity governing the size of an array used to store the elements on the queue. It is always at least as large as the queue size. As elements are added to a priority queue, its capacity grows automatically. The details of the growth policy are not specified.

This class and its enumerator implement all of the optional methods of the ICollection and IEnumerator interfaces. The enumerator provided in method GetEnumerator is not guaranteed to traverse the elements of the PriorityQueue in any particular order.

Note that this implementation is NOT synchronized. Multiple threads should not access a PriorityQueue instance concurrently if any of the threads modifies the list structurally. Instead, use the thread-safe PriorityBlockingQueue.

Remarks

Besides basic ICollection operations, queues provide additional insertion, extraction, and inspection operations.

Each of these methods exists in two forms: one throws an exception if the operation fails, the other returns a special value (either or , depending on the operation). The latter form of the insert operation is designed specifically for use with capacity-restricted IQueue implementations; in most implementations, insert operations cannot fail.

Queues typically, but do not necessarily, order elements in a FIFO (first-in-first-out) manner. Among the exceptions are priority queues, which order elements according to a supplied comparator, or the elements' natural ordering, and LIFO queues (or stacks) which order the elements LIFO (last-in-first-out). Whatever the ordering used, the head of the queue is that element which would be removed by a call to Remove or Poll. In a FIFO queue, all new elements are inserted at the tail of the queue. Other kinds of queues may use different placement rules. Every IQueue implementation must specify its ordering properties.

The Offer method inserts an element if possible, otherwise returning . This differs from the Add method, which can fail to add an element only by throwing an exception. The Offer method is designed for use when failure is a normal, rather than exceptional occurrence, for example, in fixed-capacity (or "bounded" queues.

The RemovePoll methods remove and return the head of the queue. Exactly which element is removed from the queue is a function of the queue's ordering policy, which differs from implementation to implementation. The Remove and Poll methods differ only in their behavior when the queue is empty: the Remove method throws an exception, while the Poll method returns .

The Element and Peek methods return, but do not remove, the head of the queue.

The IQueue interface does not define the blocking queue methods, which are common in concurrent programming.

IQueue implementations generally do not allow insertion of elements, although some implementations, such as a linked list, do not prohibit the insertion of . Even in the implementations that permit it, should not be inserted into a IQueue, as is also used as a special return value by the Poll method to indicate that the queue contains no elements.

IQueue implementations generally do not define element-based versions of methods Equals and GetHashCode, but instead inherit the identity based versions from the class object, because element-based equality is not always well-defined for queues with the same elements but different ordering properties.

Based on the back port of JCP JSR-166.

Requirements

Namespace: Spring.Collections

Assembly: Spring.Core (in Spring.Core.dll)

See Also

IQueue Members | Spring.Collections Namespace