@Override public void clear() { // clear all elements from the buffers // init = false; for (CircularFifoBuffer<Number> buffer : this.inputParams) { buffer.clear(); } }
/** * Returns true if this buffer is empty; false otherwise. * * @return true if this buffer is empty */ @Override public boolean isEmpty() { return (size() == 0); }
cluster.add(root); Buffer<V> queue = new UnboundedFifoBuffer<V>(); queue.add(root);
/** * Returns the next object in the buffer. * * @return the next object in the buffer * @throws BufferUnderflowException * if this buffer is empty */ @Override public E get() { if (isEmpty()) { throw new BufferUnderflowException("The buffer is already empty"); } return buffer[head]; }
@Override public E next() { if (!hasNext()) { throw new NoSuchElementException(); } lastReturnedIndex = index; index = increment(index); return buffer[lastReturnedIndex]; }
@Override public void remove() { if (lastReturnedIndex == -1) { throw new IllegalStateException(); } // First element can be removed quickly if (lastReturnedIndex == head) { UnboundedFifoBuffer.this.remove(); lastReturnedIndex = -1; return; } // Other elements require us to shift the subsequent elements int i = lastReturnedIndex + 1; while (i != tail) { if (i >= buffer.length) { buffer[i - 1] = buffer[0]; i = 0; } else { buffer[i - 1] = buffer[i]; i++; } } lastReturnedIndex = -1; tail = decrement(tail); buffer[tail] = null; index = decrement(index); }
int elements = this.inputParams.iterator().next().size(); Object firstElement = buffer.iterator().next(); if (firstElement instanceof Double) { args[argCount] = ArrayUtils.toPrimitive(buffer.toArray(new Double[0])); } else if (firstElement instanceof Integer) { args[argCount] = ArrayUtils.toPrimitive(buffer.toArray(new Integer[0])); } else { throw new IllegalArgumentException("unsupported type " + firstElement.getClass());
this.inputParams.add(new CircularFifoBuffer<Number>(this.lookbackPeriod)); for (CircularFifoBuffer<Number> buffer : this.inputParams) { Number value = (Number) params[paramCount]; buffer.add(value); paramCount++;
public GenericTALibAggregatorFunction(Method function, int inputParamCount, int lookbackPeriod, List<Object> optInputParams, Map<String, Object> outputParams, Class<?> outputClass) { super(); this.function = function; this.outputClass = outputClass; this.optInputParams = optInputParams; this.outputParams = outputParams; this.inputParams = new ArrayList<>(); for (int i = 0; i < inputParamCount; i++) { this.inputParams.add(new CircularFifoBuffer<Number>(lookbackPeriod)); } } }
cluster.add(root); Buffer<V> queue = new UnboundedFifoBuffer<V>(); queue.add(root);
if (size() + 1 >= buffer.length) { E[] tmp = (E[]) new Object[((buffer.length - 1) * 2) + 1];
/** * Removes the next object from the buffer * * @return the removed object * @throws BufferUnderflowException * if this buffer is empty */ @Override public E remove() { if (isEmpty()) { throw new BufferUnderflowException("The buffer is already empty"); } E element = buffer[head]; if (null != element) { buffer[head] = null; head++; if (head >= buffer.length) { head = 0; } } return element; }
this.inputParams.add(new CircularFifoBuffer<Number>(this.lookbackPeriod));
Buffer<V> queue = new UnboundedFifoBuffer<V>(); queue.add(source);
Buffer<V> queue = new UnboundedFifoBuffer<V>(); queue.add(source);
Buffer<V> queue = new UnboundedFifoBuffer<V>(); queue.add(s);