unsigned char array
Dependents: MGC3130 SmartLabXBeeCore
Diff: BufferedArray.cpp
- Revision:
- 2:765da30c4d9b
- Parent:
- 1:77c1ea04eb5a
--- a/BufferedArray.cpp Thu Nov 12 02:06:49 2015 +0000 +++ b/BufferedArray.cpp Thu Nov 12 02:41:54 2015 +0000 @@ -1,6 +1,6 @@ #include "BufferedArray.h" -BufferedArray::BufferedArray(int initialLength, int expandSize) +BufferedArray::BufferedArray(unsigned int initialLength, unsigned int expandSize) { this->expandSize = expandSize; max = initialLength; @@ -31,12 +31,12 @@ return data; } -unsigned char * BufferedArray::gets(int position) +unsigned char * BufferedArray::gets(unsigned long position) { return data + position; } -unsigned char BufferedArray::get(int position) +unsigned char BufferedArray::get(unsigned long position) { return *(data + position); } @@ -46,14 +46,14 @@ return index; } -void BufferedArray::setPosition(int position) +void BufferedArray::setPosition(unsigned long position) { if (this->index > max) this->index = max; else this->index = position; } -void BufferedArray::allocate(int length) +void BufferedArray::allocate(unsigned long length) { if (length <= 0) return; @@ -72,7 +72,7 @@ index = 0; } -void BufferedArray::expandSpace(int length) +void BufferedArray::expandSpace(unsigned long length) { max += expandSize * (1 + length / expandSize); unsigned char * temp = new unsigned char[max]; @@ -81,11 +81,8 @@ data = temp; } -void BufferedArray::set(int position, unsigned char value) +void BufferedArray::set(unsigned long position, unsigned char value) { - if (position < 0) - return; - if (position >= max) expandSpace(position - max + 1); @@ -98,7 +95,7 @@ index++; } -void BufferedArray::sets(const unsigned char * value, int offset, int length) +void BufferedArray::sets(const unsigned char * value, unsigned long offset, unsigned long length) { if (length <= 0) return; @@ -107,11 +104,8 @@ index += length; } -void BufferedArray::sets(int position, const unsigned char * value, int offset, int length) +void BufferedArray::sets(unsigned long position, const unsigned char * value, unsigned long offset, unsigned long length) { - if (position < 0) - return; - if (length <= 0) return;