1 #include "SlotIndexer.h"
4 * Slot indexer allows slots in both the slot buffer and the new
5 * server response to looked up in a consistent fashion.
10 SlotIndexer::SlotIndexer(Array<Slot *> *_updates, SlotBuffer *_buffer) :
13 firstslotseqnum(updates->get(0)->getSequenceNumber()) {
16 Slot *SlotIndexer::getSlot(int64_t seqnum) {
17 if (seqnum >= firstslotseqnum) {
18 int32_t offset = (int32_t) (seqnum - firstslotseqnum);
19 if (offset >= updates->length())
20 throw new Error("Invalid Slot Sequence Number Reference");
22 return updates->get(offset);
24 return buffer->getSlot(seqnum);