Java Utililty Methods Deque Usage

List of utility methods to do Deque Usage

Description

The list of methods to do Deque Usage are organized into topic(s).

Method

voidaddSegment(Deque outputBuffer, String nextSegment)
add Segment
outputBuffer.push(nextSegment);
StringbuildQueryString(final Map> params)
build Query String
StringBuilder sb = new StringBuilder();
boolean first = true;
for (Map.Entry<String, Deque<String>> entry : params.entrySet()) {
    if (entry.getValue().isEmpty()) {
        if (first) {
            first = false;
        } else {
            sb.append('&');
...
Deque[]createEmptyDequeArray(int size)
create Empty Deque Array
Deque<?>[] deque = new ArrayDeque<?>[size];
for (int i = 0; i < size; i++)
    deque[i] = new ArrayDeque<T>();
return deque;
DequeemptyDeque()
empty Deque
return EMPTY_DEQUE;
DequegetArrayDeque()
get Array Deque
return new ArrayDeque<E>();
TgetLast(List list)
get Last
if (list instanceof Deque) {
    return ((Deque<T>) list).getLast();
return list.get(list.size() - 1);
Tpop(Deque deque, T def)
Pop the first object from a deque, if it exists.
T o = def;
return deque.isEmpty() ? def : (o = deque.pop()) == null ? def : o;
voidremoveLastTest(Deque q)
remove Last Test
Object firstObject = new Object();
Object lastObject = new Object();
q.addLast(firstObject);
q.addLast(lastObject);
verify(q.removeLast() == lastObject);
verify(q.removeLast() == firstObject);
ListsplitWords(String text)
split Words
List<String> result = new ArrayList<>();
char[] chars = text.toCharArray();
int begin = 0;
boolean word = false;
for (int i = 0; i < chars.length; i++) {
    if (Character.isWhitespace(chars[i])) {
        if (word) {
            result.add(new String(chars, begin, i - begin));
...