void hashInsert(int k) {
	int p = hash(k);
	E[end].key = k;
	if(hashTable[p] < 0) {
		E[end].next = -1;
		hashTable[p] = end;
		UpdateB(p, 1);
	}
	else {
		int l=p;
		p=hashTable[p];
		if(k>=E[p].key)	{
			E[end].next=hashTable[l];
			hashTable[l]=end;
		}
		else {
			while(p>=0 && k<E[p].key) {
				l=p;
				p=E[p].next;
			}
			E[end].next = E[l].next;
			E[l].next = end;
		}
	}
	end++;
}
示例#2
0
		uint32_t CalcCRCNoCase(const char* str)
		{
			uint32_t crc = 0;
			Init(crc);
			size_t length = strlen(str);

			for (size_t i = 0; i < length; ++i)
			{
				char ch = (uint8_t)str[i];
				uint8_t b = (uint8_t)tolower(ch);

				UpdateB(crc, b);
			}

			UpdateB(crc, (uint8_t)length);
			return crc;
		}
void hashDelete(int k) {
	int p = hash(k);
	int l = p;
	p=hashTable[p];
	if(E[p].key==k) {
		hashTable[l] = E[p].next;
		if(hashTable[l] < 0)
			UpdateB(l, 0);
	}
	else {
		while(E[p].key != k) {
			l=p;
			p=E[p].next;
		}
		E[l].next=E[p].next;
	}
}