Java 类org.apache.commons.collections15.buffer.CircularFifoBuffer 实例源码

项目:CRISIS    文件:UnemploymentBasedWageAskAlgorithm.java   
public UnemploymentBasedWageAskAlgorithm(
    double initialLabourWage,
    double wageAdaptationRate,
    double minimumWage,
    EmploymentProportionCallback employmentProportionCallback
    ) {
    super(initGuard(initialLabourWage));
    if(employmentProportionCallback == null)
        throw new NullArgumentException();
    this.wagePerturbation = wageAdaptationRate * initialLabourWage;
    this.dice = new Random(
        Simulation.getSimState().random.nextLong());
    this.employmentPropCallback = employmentProportionCallback;
    this.wageConfidence = new CircularFifoBuffer<Double>(5);
    this.minimumWage = minimumWage;
    wageConfidence.add(0.0);
}
项目:AlgoTrader    文件:GenericTALibAggregatorFunction.java   
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<CircularFifoBuffer<Number>>();

    for (int i = 0; i < inputParamCount; i++) {
        this.inputParams.add(new CircularFifoBuffer<Number>(lookbackPeriod));
    }
}
项目:sstore-soft    文件:ProfileMeasurement.java   
public void enableHistoryTracking() {
    if (this.history == null) {
        synchronized (this) {
            if (this.history == null) {
                this.history = new CircularFifoBuffer<Long>(10000);
            }
        } // SYNCH
        if (debug.val)
            LOG.debug("Enabled history tracking in " + this);
    }
}
项目:s-store    文件:ProfileMeasurement.java   
public void enableHistoryTracking() {
    if (this.history == null) {
        synchronized (this) {
            if (this.history == null) {
                this.history = new CircularFifoBuffer<Long>(10000);
            }
        } // SYNCH
        if (debug.val)
            LOG.debug("Enabled history tracking in " + this);
    }
}
项目:CRISIS    文件:MedianOverHistoryStockReturnExpectationFunction.java   
/**
  * Create a {@link MedianOverHistoryStockReturnExpectationFunction}
  * object with a custom memory length (as specified by the argument).
  * 
  * @param The {@link StockReturnExpectationFunction} to which to 
  *        apply the moving median.
  * @param sizeOfMemory
  *        The length of the circular buffer over which to compute
  *        moving median returns. This argument should be strictly
  *        positive.
  */
@Inject
public MedianOverHistoryStockReturnExpectationFunction(
@Named("MEDIAN_OVER_HISTORY_PRIMITIVE_STOCK_RETURN_EXPECTATION_FUNCTION")
   StockReturnExpectationFunction expectationFunction,
@Named("MEDIAN_OVER_HISTORY_STOCK_RETURN_EXPECTATION_FUNCTION_MEMORY_LENGTH")
   final int sizeOfMemory
   ) {
   Preconditions.checkNotNull(expectationFunction);
   Preconditions.checkArgument(sizeOfMemory > 0);
   this.expectationFunction = expectationFunction;
   this.memory = new HashMap<String, CircularFifoBuffer<Double>>();
   this.sizeOfMemory = sizeOfMemory;
}
项目:CRISIS    文件:MedianOverHistoryStockReturnExpectationFunction.java   
@Override
public double computeExpectedReturn(final String stockName) {
   if(!memory.containsKey(stockName))
      memory.put(
         stockName,
         new CircularFifoBuffer<Double>(sizeOfMemory)
         );
   final double
      returnEstimate = expectationFunction.computeExpectedReturn(stockName);
   memory.get(stockName).add(returnEstimate);
   return medianOfSeries(
      ArrayUtils.asDouble(memory.get(stockName).toArray(new Double[0]))
      );
}
项目:AlgoTrader    文件:GenericTALibFunction.java   
public GenericTALibFunction() {

        super();
        this.inputParamCount = 0;
        this.inputParams = new ArrayList<CircularFifoBuffer<Number>>();
        this.optInputParams = new ArrayList<Object>();
        this.outputParams = new HashMap<String, Object>();
    }
项目:AlgoTrader    文件:GenericTALibFunction.java   
@Override
public void enter(Object obj) {

    Object[] params = (Object[]) obj;

    // add all inputs to the correct buffers
    int paramCount = 1;
    for (CircularFifoBuffer<Number> buffer : this.inputParams) {
        Number value = (Number) params[paramCount];
        buffer.add(value);
        paramCount++;
    }
}
项目:AlgoTrader    文件:GenericTALibFunction.java   
@Override
public void leave(Object obj) {

    // Remove the last element of each buffer
    for (CircularFifoBuffer<Number> buffer : this.inputParams) {
        if (buffer.contains(obj)) {
            buffer.remove(obj);
        }
    }
}
项目:AlgoTrader    文件:GenericTALibFunction.java   
@Override
public void clear() {

    // clear all elements from the buffers
    for (CircularFifoBuffer<Number> buffer : this.inputParams) {
        buffer.clear();
    }
}
项目:ProfiSounder    文件:ProfiSounderLogAppender.java   
public ProfiSounderLogAppender(int logBufferSize) {
    if (logBufferSize < 1 || logBufferSize > MAX_BUFFERSIZE)
        throw new IllegalArgumentException("logBufferSize must be between 1 and " + MAX_BUFFERSIZE + "!");

    PersistentNotifications.setConsumer(this);
    logBuffer = new CircularFifoBuffer<>(logBufferSize);
}
项目:CRISIS    文件:EmpiricalDistribution.java   
public EmpiricalDistribution(int memoryLength) {
    m_dataStream = new CircularFifoBuffer<Double>(memoryLength);
    m_sortedData = new TreeSet<EmpiricalDistribution.SortedDatum>();
    lastValueInserted = Double.NaN;
}