--- /dev/null
+#include "SlotIndexer.h"
+#include "Slot.h"
+#include "Error.h"
+#include "SlotBuffer.h"
+/**
+ * Slot indexer allows slots in both the slot buffer and the new
+ * server response to looked up in a consistent fashion.
+ * @author Brian Demsky
+ * @version 1.0
+ */
+
+SlotIndexer::SlotIndexer(Array<Slot *> *_updates, SlotBuffer *_buffer) :
+ updates(_updates),
+ buffer(_buffer),
+ firstslotseqnum(updates->get(0)->getSequenceNumber()) {
+}
+
+Slot *SlotIndexer::getSlot(int64_t seqnum) {
+ if (seqnum >= firstslotseqnum) {
+ int32_t offset = (int32_t) (seqnum - firstslotseqnum);
+ if (((uint32_t)offset) >= updates->length())
+ throw new Error("Invalid Slot Sequence Number Reference");
+ else
+ return updates->get(offset);
+ } else
+ return buffer->getSlot(seqnum);
+}