5
public StockRecord() {}7
public StockRecord(int t, int p) {15
PriorityQueue<StockRecord> max = new PriorityQueue<>((sr1, sr2) -> (sr2.price - sr1.price));16
PriorityQueue<StockRecord> min = new PriorityQueue<>((sr1, sr2) -> (sr1.price - sr2.price));17
StockRecord current_record;18
Map<Integer, Integer> map = new HashMap<>();21
current_record = new StockRecord();24
public void update(int timestamp, int price) {25
if (timestamp >= current_record.timestamp) {26
current_record.timestamp = timestamp;27
current_record.price = price;30
StockRecord sr = new StockRecord(timestamp, price);33
map.put(timestamp, price);36
public int current() {37
return current_record.price;40
public int maximum() {41
StockRecord sp = max.peek();44
if (sp.price != map.get(sp.timestamp)) max.poll();50
public int minimum() {51
StockRecord sp = min.peek();54
if (sp.price != map.get(sp.timestamp)) min.poll();