Beispiel #1
0
		bool Insert(const K& key)
		{
			if ((float)_size/(float)_capacity > 0.8)
			{
				//_CheckCapacity();
			}

			if (_size == _capacity)
			{
				cout<<"HashTable Is Full"<<endl;
				return false;
			}

			size_t pos = HashFunc1(key);
			int i = 1;
			while (_states[pos] == EXIST)
			{
				if (_tables[pos] == key)
				{
					return false;
				}
				pos = HashFunc2(pos, i++);
			}

			_tables[pos] = key;
			_states[pos] = EXIST;
			++_size;
			return true;
		}
	void Set(const K& key)
	{
		size_t index1 = HashFunc1()(key);
		size_t index2 = HashFunc2()(key);
		size_t index3 = HashFunc3()(key);
		size_t index4 = HashFunc4()(key);
		size_t index5 = HashFunc5()(key);

		cout<<index1<<" "<<index2<<" "<<index3<<" "<<index4<<" "<<index5<<endl;

		_bitSet.Set(index1%_capacity);
		_bitSet.Set(index2%_capacity);
		_bitSet.Set(index3%_capacity);
		_bitSet.Set(index4%_capacity);
		_bitSet.Set(index5%_capacity);
	}
	bool IsIn(const K& key)
	{
		size_t index1 = HashFunc1()(key);
		if (!_bitSet.Test(index1%_capacity))
			return false;

		size_t index2 = HashFunc2()(key);
		if (!_bitSet.Test(index2%_capacity))
			return false;

		size_t index3 = HashFunc3()(key);
		if (!_bitSet.Test(index3%_capacity))
			return false;

		size_t index4 = HashFunc4()(key);
		if (!_bitSet.Test(index4%_capacity))
			return false;

		size_t index5 = HashFunc5()(key);
		if (!_bitSet.Test(index5%_capacity))
			return false;

		return true;
	}