public int consume(LongConsumer consumer) { return consume(consumer, Integer.MAX_VALUE); }
/** * Adds element at head position * * @param element to add */ public boolean addElementToHead(long element) { if (size() == capacity) { return false; } elements[mapToBufferIndex(head + 1, bufferCapacity)] = element; head++; return true; } }
/** * Consumes until an element equal or greater than the argument (inclusive) or the head is reached * * @param element */ public void consumeAscendingUntilInclusive(long element) { while (head != tail && elements[mapToBufferIndex(tail + 1, bufferCapacity)] <= element) { tail++; } }
/** @return true if no more elements can be added */ public boolean isSaturated() { return size() == capacity; }
/** * Consumes until an element equal or greater than the argument (inclusive) or the head is reached * * @param element */ public void consumeAscendingUntilInclusive(long element) { while (head != tail && elements[mapToBufferIndex(tail + 1, bufferCapacity)] <= element) { tail++; } }
/** @return true if no more elements can be added */ public boolean isSaturated() { return size() == capacity; }
/** * Adds element at head position * * @param element to add */ public boolean addElementToHead(long element) { if (size() == capacity) { return false; } elements[mapToBufferIndex(head + 1, bufferCapacity)] = element; head++; return true; } }
public int consume(LongConsumer consumer, int maxElements) { int elementCounter = 0; while (head != tail && elementCounter < maxElements) { final long nextElement = elements[mapToBufferIndex(tail + 1, bufferCapacity)]; consumer.accept(nextElement); tail++; elementCounter++; } return elementCounter; }
public int consume(LongConsumer consumer) { return consume(consumer, Integer.MAX_VALUE); }
public int consume(LongConsumer consumer, int maxElements) { int elementCounter = 0; while (head != tail && elementCounter < maxElements) { final long nextElement = elements[mapToBufferIndex(tail + 1, bufferCapacity)]; consumer.accept(nextElement); tail++; elementCounter++; } return elementCounter; }