Java Doc for Queue.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » util » concurrent » locks » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Rule Engine » drolls Rule Engine » org.drools.util.concurrent.locks 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.drools.util.concurrent.locks.Queue

All known Subclasses:   org.drools.util.concurrent.locks.AbstractQueue,
Queue
public interface Queue extends Collection(Code)
A collection designed for holding elements prior to processing. Besides basic java.util.Collection Collection 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 null or false, depending on the operation). The latter form of the insert operation is designed specifically for use with capacity-restricted Queue implementations; in most implementations, insert operations cannot fail.

Throws exception Returns special value
Insert Queue.add add(e) Queue.offer offer(e)
Remove Queue.remove remove() Queue.poll poll()
Examine Queue.element element() Queue.peek peek()

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 Queue.remove() or Queue.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 Queue implementation must specify its ordering properties.

The Queue.offer offer method inserts an element if possible, otherwise returning false. This differs from the java.util.Collection.add Collection.add method, which can fail to add an element only by throwing an unchecked 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 Queue.remove() and Queue.poll() 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 null.

The Queue.element() and Queue.peek() methods return, but do not remove, the head of the queue.

The Queue interface does not define the blocking queue methods, which are common in concurrent programming. These methods, which wait for elements to appear or for space to become available, are defined in the edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue interface, which extends this interface.

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

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

This interface is a member of the Java Collections Framework.
See Also:   java.util.Collection
See Also:   LinkedList
See Also:   PriorityQueue
See Also:   edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue
See Also:   edu.emory.mathcs.backport.java.util.concurrent.BlockingQueue
See Also:   edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue
See Also:   edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue
See Also:   edu.emory.mathcs.backport.java.util.concurrent.PriorityBlockingQueue
since:
   1.5
author:
   Doug Lea





Method Summary
 booleanadd(Object e)
     Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
 Objectelement()
     Retrieves, but does not remove, the head of this queue.
 booleanoffer(Object e)
     Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions.
 Objectpeek()
     Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty.
 Objectpoll()
     Retrieves and removes the head of this queue, or returns null if this queue is empty.
 Objectremove()
     Retrieves and removes the head of this queue.



Method Detail
add
boolean add(Object e)(Code)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available.
Parameters:
  e - the element to add true (as specified by Collection.add)
throws:
  IllegalStateException - if the element cannot be added at thistime due to capacity restrictions
throws:
  ClassCastException - if the class of the specified elementprevents it from being added to this queue
throws:
  NullPointerException - if the specified element is null andthis queue not permit null elements
throws:
  IllegalArgumentException - if some property of this elementprevents it from being added to this queue



element
Object element()(Code)
Retrieves, but does not remove, the head of this queue. This method differs from Queue.peek peek only in that it throws an exception if this queue is empty. the head of this queue
throws:
  NoSuchElementException - if this queue is empty



offer
boolean offer(Object e)(Code)
Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to Queue.add , which can fail to insert an element only by throwing an exception.
Parameters:
  e - the element to add true if the element was added to this queue, elsefalse
throws:
  ClassCastException - if the class of the specified elementprevents it from being added to this queue
throws:
  NullPointerException - if the specified element is null andthis queue does not permit null elements
throws:
  IllegalArgumentException - if some property of this elementprevents it from being added to this queue



peek
Object peek()(Code)
Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty. the head of this queue, or null if this queue is empty



poll
Object poll()(Code)
Retrieves and removes the head of this queue, or returns null if this queue is empty. the head of this queue, or null if this queue is empty



remove
Object remove()(Code)
Retrieves and removes the head of this queue. This method differs from Queue.poll poll only in that it throws an exception if this queue is empty. is empty. the head of this queue
throws:
  NoSuchElementException - if this queue is empty



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.