Java collections framework: Difference between revisions

Content deleted Content added
EnumSet class: Add more information about EnumSet
Double-ended queue (Deque) interfaces: Add inline citation. Fixed formatting.
Line 166:
 
===Double-ended queue (Deque) interfaces===
The <code>{{java|java.util.Deque}} interface extends the {{java|Queue</code>}} interface. is{{sfn|Goetz|Peierls|Bloch|Bowbeer|2006|loc=§5.3.3 expandedDeques byand thework <code>stealing|p=92}}{{java|java.util.Deque</code> subinterface. <code>Deque</code>}} creates a double-ended queue. While a regular <code>Queue</code> only allows insertions at the rear and removals at the front, the <code>{{java|Deque</code>}} allows insertions or removals to take place both at the front and the back. A <code>Deque</code> is like a <code>Queue</code> that can be used forwards or backwards, or both at once. Additionally, both a forwards and a backwards iterator can be generated. The <code>{{java|Deque</code>}} interface is implemented by <code>java.util.ArrayDeque</code> and <code>java.util.LinkedList</code>.<ref>{{cite web|url=http://docs.oracle.com/javase/7/docs/api/java/util/Deque.html |title=Deque (Java Platform SE 7 ) |publisher=Docs.oracle.com |date=2013-06-06 |access-date=2013-08-16}}</ref>
 
====Deque implementations====
Line 177:
<code>ArrayDeque</code> implements the <code>Queue</code> as an array. Similar to <code>LinkedList</code>, <code>ArrayDeque</code> also implements the '''{{Javadoc|module=java.base|package=java.util|class=Deque|monotype=y}}''' interface.<ref>{{cite web|url=http://docs.oracle.com/javase/7/docs/api/java/util/Queue.html |title=Queue (Java Platform SE 7) |publisher=Docs.oracle.com |date=2013-06-06 |access-date=2013-08-16}}</ref>
====BlockingDeque interface====
The '''{{Javadoc:SE|module=java.base|package=java.util.concurrent|java/util/concurrent|BlockingDeque}}''' interface works similarly to <code>java.util.concurrent.BlockingQueue</code>. The same methods for insertion and removal with time limits for waiting for the insertion or removal to become possible are provided. However, the interface also provides the flexibility of a <code>{{java|Deque</code>}}. Insertions and removals can take place at both ends. The blocking function is combined with the <code>Deque</code> function.<ref>{{cite web|url=http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/BlockingDeque.html |title=BlockingDeque (Java Platform SE 7 ) |publisher=Docs.oracle.com |date=2013-06-06 |access-date=2013-08-16}}</ref>
 
==Set interfaces==