List of usage examples for org.apache.commons.collections15.buffer PriorityBuffer get
public E get()
From source file:edu.cuny.cat.market.matching.FourHeapShoutEngine.java
/** * Unify the shout at the top of the heap with the supplied shout, so that * quantity(shout) = quantity(top(heap)). This is achieved by splitting the * supplied shout or the shout at the top of the heap. * /* w w w. j a va2 s . c o m*/ * @param shout * The shout. * @param heap * The heap. * * @return A reference to the, possibly modified, shout. * */ protected static Shout unifyShout(Shout shout, final PriorityBuffer<Shout> heap) { final Shout top = heap.get(); if (shout.getQuantity() > top.getQuantity()) { shout = shout.splat(shout.getQuantity() - top.getQuantity()); } else { if (top.getQuantity() > shout.getQuantity()) { final Shout remainder = top.split(top.getQuantity() - shout.getQuantity()); heap.add(remainder); } } return shout; }