List of utility methods to do Queue Usage
double | addElementsToQueueInSingleThread(int numberOfElements, Queue add Elements To Queue In Single Thread long t = System.nanoTime(); for (int i = 0; i < numberOfElements; i++) { queue.add(element); t = System.nanoTime() - t; return t / Math.pow(10, 9); |
Queue | addStringArraytoQueue(Queue add String Arrayto Queue for (String string : array) { set.add(string); return set; |
String | asString(Queue as String StringBuilder sb = new StringBuilder(); sb.append("["); boolean first = true; for (byte[] bs : values) { if (first) { first = false; } else { sb.append(", "); ... |
String | bQToString(Queue b Q To String byte[] bytes = new byte[bQ.size()]; for (int i = 0; i < bytes.length; i++) { bytes[i] = bQ.poll(); return new String(bytes); |
List | convertQueueToArray(Queue convert Queue To Array Queue<K> temp = new PriorityQueue<K>(q); List<K> list = new ArrayList<K>(); while (temp.size() > 0) list.add(temp.poll()); return list; |
void | elementFail(Queue element Fail try { q.element(); throw new RuntimeException("Exception should have thrown"); } catch (NoSuchElementException e) { |
E | get(Queue get E result = null; int i = 0; for (E e : queue) { if (i == index) { result = e; break; i++; ... |
List | getAllElementsFromQueueAsList(Queue get All Elements From Queue As List final int size = queue.size(); List<Type> result = new ArrayList<>(); for (int i = 0; i < size; i++) { result.add(queue.poll()); return result; |
boolean | isListBased(Class type) Return whether the supplied type (collection) is list based. if (type == null) { return false; } else if (java.util.List.class.isAssignableFrom(type)) { return true; } else if (java.util.Queue.class.isAssignableFrom(type)) { return true; return false; ... |
boolean | isQueue(final Object value, final boolean acceptNull) Returns true if the given object is an instance of Queue . return isType(Queue.class, value, acceptNull); |