X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=version2%2Fsrc%2FC%2FSlotBuffer.cc;h=de4bbe0bc64a43f14851d46b2eb401dbeacbc409;hb=2d567b75be4055f6a40ffe1cedb5cdc9be262d86;hp=91ac22edc1e6667c2fce73d7cfd3dbba06c03402;hpb=ec6b65ba09fe295c36621a3386cb2571a8833203;p=iotcloud.git diff --git a/version2/src/C/SlotBuffer.cc b/version2/src/C/SlotBuffer.cc index 91ac22e..de4bbe0 100644 --- a/version2/src/C/SlotBuffer.cc +++ b/version2/src/C/SlotBuffer.cc @@ -1,4 +1,5 @@ -#include"SlotBuffer.h" +#include "SlotBuffer.h" +#include "Slot.h" /** * Circular buffer that holds the live set of slots. * @author Brian Demsky @@ -25,8 +26,8 @@ int SlotBuffer::capacity() { void SlotBuffer::resize(int newsize) { if (newsize == (array->length() - 1)) return; - - Array * newarray = new Array(newsize + 1); + + Array *newarray = new Array(newsize + 1); int currsize = size(); int index = tail; for (int i = 0; i < currsize; i++) { @@ -51,9 +52,9 @@ void SlotBuffer::incrementTail() { tail = 0; } -void SlotBuffer::putSlot(Slot * s) { +void SlotBuffer::putSlot(Slot *s) { int64_t checkNum = (getNewestSeqNum() + 1); - + if (checkNum != s->getSequenceNumber()) { // We have a gap so expunge all our slots oldestseqn = s->getSequenceNumber(); @@ -62,10 +63,10 @@ void SlotBuffer::putSlot(Slot * s) { array->set(0, s); return; } - + array->set(head, s); incrementHead(); - + if (oldestseqn == 0) { oldestseqn = s->getSequenceNumber(); } @@ -76,7 +77,7 @@ void SlotBuffer::putSlot(Slot * s) { } } -Slot SlotBuffer::getSlot(int64_t seqnum) { +Slot *SlotBuffer::getSlot(int64_t seqnum) { int32_t diff = (int32_t) (seqnum - oldestseqn); int32_t index = diff + tail; @@ -92,7 +93,7 @@ Slot SlotBuffer::getSlot(int64_t seqnum) { index -= array->length(); } - if (index >= array->length) { + if (index >= array->length()) { return NULL; }