public class PriceComparator extends java.lang.Object implements java.util.Comparator<TradeOrder>
Constructor and Description |
---|
PriceComparator()
Constructs a price comparator that compares two orders in
ascending order.
|
PriceComparator(boolean asc)
Constructs a price comparator that compares two orders in
ascending or descending order.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(TradeOrder order1,
TradeOrder order2)
Compares two trade orders.
|
public PriceComparator()
boolean ascending
flag to true
.public PriceComparator(boolean asc)
boolean ascending
flag to asc
.asc
- if true, make an ascending comparator;
otherwise make a descending comparator.public int compare(TradeOrder order1, TradeOrder order2)
compare
in interface java.util.Comparator<TradeOrder>
order1
- the first orderorder2
- the second orderorder1
is market and order2
is limit;order1
is limit and order2
is market;order1
and order2
are limit orders.
In the latter case, the difference returned is cents1 - cents2 or cents2 - cents1,
depending on whether this is an ascending or descending comparator
(ascending
is true
or false
).