Summer.Batch.Common.Collections.AbstractPriorityQueue< T > Class Template Referenceabstract

Abstract Priority Queue. More...

Inheritance diagram for Summer.Batch.Common.Collections.AbstractPriorityQueue< T >:
Summer.Batch.Common.Collections.IQueue< T > Summer.Batch.Common.Collections.PriorityBlockingQueue< T > Summer.Batch.Common.Collections.PriorityQueue< T >

Public Member Functions

abstract T Poll ()
 Removes the head of the queue and returns it. More...
 
virtual T Peek ()
 Returns the head of the queue without removing it. More...
 
abstract void Add (T item)
 Adds an item to the queue. The item is added at the correct position according to the current order. More...
 
abstract void Clear ()
 Clears the queue. More...
 
abstract bool Contains (T item)
 Checks if an element is inside the queue. The comparison is done using the current order rather than object.Equals(object). More...
 
virtual void CopyTo (T[] array, int arrayIndex)
 Copies the elements of the queue to an array, preserving the order. More...
 
abstract bool Remove (T item)
 Removes an item from the queue. More...
 
IEnumerator< T > GetEnumerator ()
 

Protected Member Functions

 AbstractPriorityQueue (IComparer< T > comparer=null)
 Constructs a new priority queue with a default capacity and no elements. More...
 
 AbstractPriorityQueue (int capacity, IComparer< T > comparer=null)
 Constructs a new priority queue with the specified capacity and no elements. More...
 
 AbstractPriorityQueue (IEnumerable< T > enumerable, IComparer< T > comparer=null)
 Constructs a new priority queue and initializes it with the given elements. More...
 
DoPoll ()
 Removes the head and returns it. More...
 
void DoAdd (T item)
 Adds an item to the queue. More...
 
void DoClear ()
 Clears the queue. More...
 
bool DoRemove (T item)
 Removes an item from the queue. More...
 
bool DoContains (T item)
 Checks if an item is present in the queue. More...
 

Properties

IComparer< T > Comparer [get, protected set]
 The comparer used to order the elements in the queue. Can be null if T implements IComparable<T>. More...
 
virtual int Count [get]
 The number of elements in the queue. More...
 
bool IsReadOnly [get]
 Always false More...
 
int Capacity [get, set]
 The internal capacity of the internal array. It is automatically expended when needed. Can be set if it can be estimated, thus avoiding multiple resize, or to reduce its size if the number of elements has been considerably reduced. More...
 

Detailed Description

Abstract Priority Queue.

Template Parameters
T The type of the elements in the queue.

Constructor & Destructor Documentation

Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.AbstractPriorityQueue ( IComparer< T >  comparer = null)
protected

Constructs a new priority queue with a default capacity and no elements.

Parameters
comparerthe comparer to use for ordering elements
Exceptions
InvalidOperationException  if T does not implement IComparable<T> and comparer is null.
Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.AbstractPriorityQueue ( int  capacity,
IComparer< T >  comparer = null 
)
protected

Constructs a new priority queue with the specified capacity and no elements.

Parameters
capacitythe initial capacity
comparerthe comparer to use for ordering elements
Exceptions
InvalidOperationException  if T does not implement IComparable<T> and comparer is null.
Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.AbstractPriorityQueue ( IEnumerable< T >  enumerable,
IComparer< T >  comparer = null 
)
protected

Constructs a new priority queue and initializes it with the given elements.

Parameters
enumerablean enumerable containing the initial elements
comparerthe comparer to use for ordering elements
Exceptions
InvalidOperationException  if T does not implement IComparable<T> and comparer is null.

Member Function Documentation

abstract void Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.Add ( item)
pure virtual

Adds an item to the queue. The item is added at the correct position according to the current order.

Parameters
itemthe item to add

Implemented in Summer.Batch.Common.Collections.PriorityBlockingQueue< T >, and Summer.Batch.Common.Collections.PriorityQueue< T >.

abstract bool Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.Contains ( item)
pure virtual

Checks if an element is inside the queue. The comparison is done using the current order rather than object.Equals(object).

Parameters
itemthe item to check
Returns
true if there is an item with the same order as item ; false otherwise

Implemented in Summer.Batch.Common.Collections.PriorityBlockingQueue< T >, and Summer.Batch.Common.Collections.PriorityQueue< T >.

virtual void Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.CopyTo ( T[]  array,
int  arrayIndex 
)
virtual

Copies the elements of the queue to an array, preserving the order.

Parameters
arraythe array to copy the elements to
arrayIndexthe index where to start copying
Exceptions
ArgumentOutOfRangeException  if the size of array is lower than arrayIndex + Count.

Reimplemented in Summer.Batch.Common.Collections.PriorityBlockingQueue< T >.

void Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.DoAdd ( item)
protected

Adds an item to the queue.

Parameters
itemThe item to add.

Clears the queue.

bool Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.DoContains ( item)
protected

Checks if an item is present in the queue.

Parameters
itemThe item to search for.
Returns
true if item is present in the queue, false otherwise.

Removes the head and returns it.

Returns
The element that was previously the head of the queue, or default(T) if the queue was empty.
bool Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.DoRemove ( item)
protected

Removes an item from the queue.

Parameters
itemThe item to remove
Returns
true if the item was actually removed; false otherwise.
IEnumerator<T> Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.GetEnumerator ( )

See also
IEnumerable::GetEnumerator
Returns

Returns the head of the queue without removing it.

Returns
the head of the queue

Implements Summer.Batch.Common.Collections.IQueue< T >.

Reimplemented in Summer.Batch.Common.Collections.PriorityBlockingQueue< T >.

abstract T Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.Poll ( )
pure virtual

Removes the head of the queue and returns it.

Returns
the head of the queue

Implements Summer.Batch.Common.Collections.IQueue< T >.

Implemented in Summer.Batch.Common.Collections.PriorityQueue< T >, and Summer.Batch.Common.Collections.PriorityBlockingQueue< T >.

abstract bool Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.Remove ( item)
pure virtual

Removes an item from the queue.

Parameters
itemthe item to remove
Returns
true if the item was removed from the queue; false otherwise

Implemented in Summer.Batch.Common.Collections.PriorityBlockingQueue< T >, and Summer.Batch.Common.Collections.PriorityQueue< T >.

Property Documentation

The internal capacity of the internal array. It is automatically expended when needed. Can be set if it can be estimated, thus avoiding multiple resize, or to reduce its size if the number of elements has been considerably reduced.

IComparer<T> Summer.Batch.Common.Collections.AbstractPriorityQueue< T >.Comparer
getprotected set

The comparer used to order the elements in the queue. Can be null if T implements IComparable<T>.

The number of elements in the queue.

Always false


The documentation for this class was generated from the following file:
  • Summer.Batch.Common/Collections/AbstractPriorityQueue.cs