#include "array.h"
#include <string.h>
+#include <stdio.h>
/**
* IoTString wraps the underlying char string.
* @author Brian Demsky <bdemsky@uci.edu>
uint len = array->length();
unsigned int hash = 0;
for (uint i = 0; i < len; i++) {
- hash = 31 * hash + array->get(i);
+ hash = 31 * hash + ((unsigned int) array->get(i));
}
return hash;
}
}
IoTString(IoTString *string) :
- array(new Array<char>(string->array)),
- hashvalue(hashCharArray(array)) {
+ array(new Array<char>(string->array)),
+ hashvalue(string->hashvalue) {
}
~IoTString() {
delete array;
}
+ void print() {
+ for(uint i=0; i < array->length(); i++)
+ printf("%c", array->get(i));
+ };
+
char get(uint i) {return array->get(i);}
/**
* Returns the length in chars of the IoTString.
*/
+
bool equals(IoTString *str) {
uint strlength = str->array->length();
uint thislength = array->length();
inline IoTString *IoTString_shallow(Array<char> *_array) {
IoTString *str = new IoTString();
str->array = _array;
+ str->hashvalue = hashCharArray(_array);
return str;
}