mirror of
				https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
				synced 2025-10-30 18:17:50 +00:00 
			
		
		
		
	trunk/branch integration: hash buckets
This commit is contained in:
		| @@ -364,13 +364,16 @@ public: | ||||
| 		/// pair(iterator, true) with iterator | ||||
| 		/// pointing to the new element is returned. | ||||
| 	{ | ||||
| 		split(); | ||||
| 		std::size_t addr = bucketAddress(value); | ||||
| 		std::size_t hash = _hash(value); | ||||
| 		std::size_t addr = bucketAddressForHash(hash); | ||||
| 		BucketVecIterator it(_buckets.begin() + addr); | ||||
| 		BucketIterator buckIt(std::find(it->begin(), it->end(), value)); | ||||
| 		if (buckIt == it->end()) | ||||
| 		{ | ||||
| 			buckIt = it->insert(buckIt, value); | ||||
| 			split(); | ||||
| 			addr = bucketAddressForHash(hash); | ||||
| 			it = _buckets.begin() + addr; | ||||
| 			buckIt = it->insert(it->end(), value); | ||||
| 			++_size; | ||||
| 			return std::make_pair(Iterator(it, _buckets.end(), buckIt), true); | ||||
| 		} | ||||
| @@ -417,6 +420,12 @@ public: | ||||
| 		return _size == 0; | ||||
| 	} | ||||
| 	 | ||||
| 	std::size_t buckets() const | ||||
| 		/// Returns the number of allocated buckets. | ||||
| 	{ | ||||
| 		return _buckets.size(); | ||||
| 	} | ||||
| 	 | ||||
| protected: | ||||
| 	std::size_t bucketAddress(const Value& value) const | ||||
| 	{ | ||||
| @@ -427,6 +436,14 @@ protected: | ||||
| 			return n % (2*_front); | ||||
| 	} | ||||
| 	 | ||||
| 	std::size_t bucketAddressForHash(std::size_t hash) | ||||
| 	{ | ||||
| 		if (hash % _front >= _split) | ||||
| 			return hash % _front; | ||||
| 		else | ||||
| 			return hash % (2*_front); | ||||
| 	} | ||||
| 	 | ||||
| 	void split() | ||||
| 	{ | ||||
| 		if (_split == _front) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Marian Krivos
					Marian Krivos