Queue Interface

...


Queue extends Collection.

The interface enforces two sets of three different methods designed to pull, put and check elements on a queue. Each set differes in thier reaction to a failure (abend).

Methods...

  • add and offer both insert elements on to the queue.
  • remove and poll remove the element from the head of the queue.
  • element and peek return an element but do nothing to to queue

0 DigIts

0 Comments

no Shares

CREATED 2013-09-08 13:58:26.0

00-1C-8A

UPDATED 2013-09-08 14:01:45.0

The Exception Set...


add(e) will throw an IllegalStateException if operating on a Bounded queue (a queue with a size restriction) when adding an element will increase the queue's size beyond its limit

Adversely, remove() and element() will throw a NoSuchElementException when acting on an empty queue

add(e) will throw an IllegalStateException if operating on a Bounded queue (a queue with a size restriction) when adding an element will increase the queue's size beyond its limit

Adversely, remove() and element() will throw a NoSuchElementException when acting on an empty queue

0 DigIts

0 Comments

no Shares

CREATED 2013-09-08 14:00:06.0

00-1C-8B

UPDATED 2013-09-08 14:01:43.0

The Passive Set...


offer(e), poll() and peek() are passive methods in that they don't throw exceptions instead return a null or false value.

While poll() and peek() will return a null value if the operation either fails or the queue is in an empty state.

While poll() and peek() will return a null value if the operation either fails or the queue is in an empty state.

0 DigIts

0 Comments

no Shares

CREATED 2013-09-08 14:00:26.0

00-1C-8C

UPDATED 2013-09-08 14:01:42.0

Bounded Queus...


Bounded queue's (some queue implementations in the java.util.concurrent package) restrict the number of elements that can be in the queue. All queue's in the java.util package are Unbounded.

0 DigIts

0 Comments

no Shares

CREATED 2013-09-08 14:00:44.0

00-1C-8D

UPDATED 2013-09-08 14:01:40.0

Ordering...


Queue's tipically use FIFO ordering but there are exceptions...

Elements pulled from the queue (remove() and poll()) are always pulled from the head of the queue regardless of the ordering while inserted items (add() and offer()) are placed at the tail end of the queue in FIFO ordering but may be implementation specific. Each implementation of Queue MUST specify its ordering.

0 DigIts

0 Comments

no Shares

CREATED 2013-09-08 14:01:01.0

00-1C-8E

UPDATED 2013-09-08 14:01:38.0

Nulls...


Because some passive methods of queue (poll() and peek()) return null nulls are not permitted in queue's. However there are exceptions such as the LinkedList mainly because the interface came after LinkedList. Therefore, it allows nulls but would not be a good practice. Other implementations of Queue do not. Queue

0 DigIts

0 Comments

no Shares

CREATED 2013-09-08 14:01:19.0

00-1C-8F

UPDATED 2013-09-08 14:01:49.0

Knowledge

L
I
N
K
S

DBID: db.wam

Page Server: Ruger

©2012 Leistware Data Systems

      Hello anonymous