Package com.tangosol.util
Class Dequeue
- java.lang.Object
-
- com.tangosol.util.Base
-
- com.tangosol.util.Dequeue
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Enumeration
,Iterator
public class Dequeue extends Base implements Enumeration, Iterator, Cloneable, Serializable
Represents a double-ended queue (dequeue) of objects. A dequeue allows items which have been removed from the front of the queue to be put back on the front of the queue.- Version:
- 1.00, 12/05/96
- Author:
- Cameron Purdy
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Constructor Summary
Constructors Constructor Description Dequeue()
Constructs a dequeue.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addElement(Object o)
Adds an element to the dequeue.int
capacity()
Determine the current capacity of this dequeue.Object
clone()
Creates a clone of the dequeue.protected void
grow()
Increase the capacity of the Dequeue.boolean
hasMoreElements()
Determines if the Dequeue contains more elements.boolean
hasNext()
Tests if this Iterator contains more elements.boolean
isEmpty()
Determines if the dequeue is empty.boolean
isFull()
Determines if the dequeue is full.Object
next()
Returns the next element of this Iterator.protected int
next(int i)
Determines the index following the passed index for storing or accessing an item from the m_ao storage.Object
nextElement()
Returns the next element from the Dequeue.protected int
prev(int i)
Determines the index preceding the passed index for storing or accessing an item from the m_ao storage.void
putBackElement(Object o)
Returns the most recently returned element to the Dequeue.void
remove()
Remove the last-returned element that was returned by the Iterator.void
removeAllElements()
Removes all items from the dequeue.int
size()
Determine the current number of objects in this dequeue.-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Enumeration
asIterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Method Detail
-
hasMoreElements
public boolean hasMoreElements()
Determines if the Dequeue contains more elements.- Specified by:
hasMoreElements
in interfaceEnumeration
- Returns:
- true if Dequeue contains more elements, false otherwise
-
nextElement
public Object nextElement() throws NoSuchElementException
Returns the next element from the Dequeue. Calls to this method will enumerate successive elements.- Specified by:
nextElement
in interfaceEnumeration
- Returns:
- the next element
- Throws:
NoSuchElementException
- If no more elements exist.
-
hasNext
public boolean hasNext()
Tests if this Iterator contains more elements.
-
next
public Object next()
Returns the next element of this Iterator.
-
remove
public void remove()
Remove the last-returned element that was returned by the Iterator. This method always throws UnsupportedOperationException because the Iterator is immutable.
-
addElement
public void addElement(Object o)
Adds an element to the dequeue. The passed object is placed at the end of the dequeue.- Parameters:
o
- object to add to the Dequeue
-
putBackElement
public void putBackElement(Object o)
Returns the most recently returned element to the Dequeue. After calling this method, a call to nextElement will return the element that was returned by the most recent call to nextElement. This method can be called multiple times to put back multiple elements.- Parameters:
o
- the object- Throws:
NoSuchElementException
- If the element that is being put back is no longer in the Dequeue.
-
removeAllElements
public void removeAllElements()
Removes all items from the dequeue.
-
capacity
public int capacity()
Determine the current capacity of this dequeue.- Returns:
- the current capacity of this dequeue
-
size
public int size()
Determine the current number of objects in this dequeue.- Returns:
- the current number of objects in this dequeue
-
isEmpty
public boolean isEmpty()
Determines if the dequeue is empty.- Returns:
- true if the dequeue is empty, false otherwise
-
isFull
public boolean isFull()
Determines if the dequeue is full. This method is mainly of use internally, since the dequeue auto-resizes when additional items are added.- Returns:
- true if the dequeue is full, false otherwise
-
clone
public Object clone()
Creates a clone of the dequeue.
-
next
protected int next(int i)
Determines the index following the passed index for storing or accessing an item from the m_ao storage.- Parameters:
i
- the index- Returns:
- the next index
-
prev
protected int prev(int i)
Determines the index preceding the passed index for storing or accessing an item from the m_ao storage.- Parameters:
i
- the index- Returns:
- the previous index
-
grow
protected void grow()
Increase the capacity of the Dequeue.
-
-