- All Implemented Interfaces:
Iterable<Long>,Collection<Long>,Deque<Long>,Queue<Long>,SequencedCollection<Long>,LongDeque
A
long-valued deque backed by a primitive array.- Author:
- Werner Randelshofer
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance with an initial capacity for 8 elements.LongArrayDeque(int capacity) Creates a new instance with the specified initial capacity rounded up to the next strictly positive power of two. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFirstAsLong(long e) voidaddFirstAsLongBranchless(long e, boolean reallyAdd) Adds first using branch-less code that takes advantage of the out-of-order execution unit in the CPU.voidaddLastAllAsLong(long @NonNull [] array) voidaddLastAllAsLong(long @NonNull [] array, int offset, int length) voidaddLastAsLong(long e) voidaddLastAsLongBranchless(long e, boolean reallyAdd) Adds last using branch-less code that takes advantage of the out-of-order execution unit in the CPU.voidclear()Clears the deque in O(1).element()booleanintfirstIndexOfAsLong(long o) Returns the first index of the specified element or -1 if this deque does not contain the element.longlonginthashCode()booleanisEmpty()Returns true if this deque is empty.iterator()intlastIndexOfAsLong(long o) Returns the last index of the specified element or -1 if this deque does not contain the element.voidremoveAt(int i) Removes an element at the given array index.longRemoves the element at the head of the deque.booleanremoveFirstOccurrenceAsLong(long o) longbooleanremoveLastOccurrenceAsLong(long o) intsize()toString()Methods inherited from class java.util.AbstractCollection
add, addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
containsAll, parallelStream, removeAll, removeIf, retainAll, spliterator, stream, toArray, toArray, toArrayMethods inherited from interface org.jhotdraw8.collection.primitive.LongDeque
add, addFirst, addLast, contains, getFirst, getLast, offer, offerFirst, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollLast, pop, popAsLong, push, pushAsLong, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence
-
Constructor Details
-
LongArrayDeque
public LongArrayDeque()Creates a new instance with an initial capacity for 8 elements. -
LongArrayDeque
public LongArrayDeque(int capacity) Creates a new instance with the specified initial capacity rounded up to the next strictly positive power of two.- Parameters:
capacity- initial capacity
-
-
Method Details
-
addFirstAsLong
public void addFirstAsLong(long e) - Specified by:
addFirstAsLongin interfaceLongDeque- See Also:
-
addFirstAsLongBranchless
public void addFirstAsLongBranchless(long e, boolean reallyAdd) Adds first using branch-less code that takes advantage of the out-of-order execution unit in the CPU.- Parameters:
e- an elementreallyAdd- true if this element should really be added
-
addLastAllAsLong
-
addLastAllAsLong
-
addLastAsLong
public void addLastAsLong(long e) - Specified by:
addLastAsLongin interfaceLongDeque- See Also:
-
addLastAsLongBranchless
public void addLastAsLongBranchless(long e, boolean reallyAdd) Adds last using branch-less code that takes advantage of the out-of-order execution unit in the CPU.- Parameters:
e- an elementreallyAdd- true if this element should really be added
-
clear
public void clear()Clears the deque in O(1).- Specified by:
clearin interfaceCollection<Long>- Overrides:
clearin classAbstractCollection<Long>
-
descendingIterator
- Specified by:
descendingIteratorin interfaceDeque<Long>
-
element
-
equals
- Specified by:
equalsin interfaceCollection<Long>- Overrides:
equalsin classObject
-
firstIndexOfAsLong
public int firstIndexOfAsLong(long o) Description copied from interface:LongDequeReturns the first index of the specified element or -1 if this deque does not contain the element.- Specified by:
firstIndexOfAsLongin interfaceLongDeque
-
getFirstAsLong
public long getFirstAsLong()- Specified by:
getFirstAsLongin interfaceLongDeque- Throws:
NoSuchElementException- if the queue is empty- See Also:
-
getLastAsLong
public long getLastAsLong()- Specified by:
getLastAsLongin interfaceLongDeque- Throws:
NoSuchElementException- if the queue is empty- See Also:
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<Long>- Overrides:
hashCodein classObject
-
isEmpty
public boolean isEmpty()Returns true if this deque is empty.- Specified by:
isEmptyin interfaceCollection<Long>- Overrides:
isEmptyin classAbstractCollection<Long>- Returns:
trueif this deque contains no elements
-
iterator
-
lastIndexOfAsLong
public int lastIndexOfAsLong(long o) Description copied from interface:LongDequeReturns the last index of the specified element or -1 if this deque does not contain the element.- Specified by:
lastIndexOfAsLongin interfaceLongDeque
-
removeAt
public void removeAt(int i) Removes an element at the given array index. -
removeFirstAsLong
public long removeFirstAsLong()Removes the element at the head of the deque.- Specified by:
removeFirstAsLongin interfaceLongDeque- Throws:
NoSuchElementException- if the queue is empty- See Also:
-
removeFirstOccurrenceAsLong
public boolean removeFirstOccurrenceAsLong(long o) - Specified by:
removeFirstOccurrenceAsLongin interfaceLongDeque- See Also:
-
removeLastAsLong
public long removeLastAsLong()- Specified by:
removeLastAsLongin interfaceLongDeque- See Also:
-
removeLastOccurrenceAsLong
public boolean removeLastOccurrenceAsLong(long o) - Specified by:
removeLastOccurrenceAsLongin interfaceLongDeque
-
size
public int size()- Specified by:
sizein interfaceCollection<Long>- Specified by:
sizein interfaceDeque<Long>- Specified by:
sizein classAbstractCollection<Long>
-
toString
- Overrides:
toStringin classAbstractCollection<Long>
-