int* LBEHashMap::get(std::string key) {
	lock.lock();
	char* hash = hashKey(key, keySize);
	Node* local = head;

	for (int R = 0; R < keySize; R += 1) {
		int pos = (int) hash[R];
		Node* node = getNode(local, pos);
		if (isArrayNode(node)) {
			local = node;
		} else {
			DataNode* dataNode = dynamic_cast<DataNode*>(node);
			if ((dataNode != nullptr) && hashEqual(dataNode->getHash(), hash, keySize)) {
				lock.unlock();
				return &(dataNode->value);
			} else {
				lock.unlock();
				return nullptr;
			}
		}
	}

	lock.unlock();
	return nullptr;
}
bool LBEHashMap::put(std::string key, int value) {
	lock.lock();
	char* hash = hashKey(key, keySize);
	Node* insertThis = allocateNode(value, key, keySize);
	Node* local = head;

	for (int R = 0; R < keySize; R++) {
		int pos = (int) hash[R];
		Node* node = getNode(local, pos);
		if (isArrayNode(node)) {
			local = node;
		} else {
			DataNode* dataNode = dynamic_cast<DataNode*>(node);
			if (dataNode == nullptr) {
				//adding new node
				dynamic_cast<ArrayNode*>(local)->array[pos] = insertThis;
				lock.unlock();
				return true;
			} else if (hashEqual(dataNode->getHash(), hash, keySize)) {
				//replace old node
				dynamic_cast<ArrayNode*>(local)->array[pos] = insertThis;
				delete node;
				lock.unlock();
				return true;
			} else {
				//expand
				local = expandTable(local, pos, insertThis, R);
			}
		}
	}

	lock.unlock();
	return false;
}