19 #if !defined(XALANMAP_HEADER_GUARD_1357924680)
20 #define XALANMAP_HEADER_GUARD_1357924680
43 #pragma warning(disable: 4189)
54 const char *byteArray =
reinterpret_cast<const char*
>(&key);
58 for (
size_type i = 0; i <
sizeof(Key); ++i)
60 result = (result << 1) ^ byteArray[i];
98 template <
class Value>
106 template <
class Value>
114 template <
class XalanMapTraits,
class BaseIterator>
119 typedef typename XalanMapTraits::pointer
pointer;
129 baseIterator(theRhs.baseIterator)
153 return *baseIterator->value;
158 return baseIterator->value;
168 return !(theRhs == *
this);
236 eDefaultMinBuckets = 29u,
237 eDefaultEraseThreshold = 50u,
238 eMinimumBucketSize = 5u
243 MemoryManager& theMemoryManager,
244 double loadFactor = 0.75,
245 size_type minBuckets = eDefaultMinBuckets,
246 size_type eraseThreshold = eDefaultEraseThreshold) :
247 m_memoryManager(&theMemoryManager),
248 m_loadFactor(loadFactor),
249 m_minBuckets(minBuckets),
251 m_entries(theMemoryManager),
252 m_freeEntries(theMemoryManager),
253 m_buckets(theMemoryManager),
255 m_eraseThreshold(eraseThreshold)
261 MemoryManager& theMemoryManager) :
262 m_memoryManager(&theMemoryManager),
263 m_loadFactor(theRhs.m_loadFactor),
264 m_minBuckets(theRhs.m_minBuckets),
266 m_entries(theMemoryManager),
267 m_freeEntries(theMemoryManager),
269 size_type(m_loadFactor * theRhs.size()) + 1,
273 m_eraseThreshold(theRhs.m_eraseThreshold)
277 while(entry != theRhs.
end())
283 assert(m_size == theRhs.
m_size);
289 assert (m_memoryManager != 0);
291 return *m_memoryManager;
298 if (!m_buckets.empty())
302 while(toRemove != m_freeEntries.end())
304 deallocate(toRemove->value);
313 XalanMap theTemp(theRhs, *m_memoryManager);
332 return m_entries.begin();
337 return const_cast<XalanMap*
>(
this)->begin();
342 return m_entries.end();
347 return const_cast<XalanMap*
>(
this)->end();
354 assert(m_buckets.empty() ==
false);
357 assert(index < m_buckets.size());
362 while (pos != bucket.
end())
364 if (!(*pos)->erased && m_equals(key, (*pos)->value->first))
377 return const_cast<XalanMap *
>(
this)->find(key);
386 pos = doCreateEntry(key);
389 return (*pos).second;
395 insert(value.first, value.second);
404 doCreateEntry(key, &data);
438 while (bucketPos != m_buckets.end())
447 assert(m_entries.empty());
456 MemoryManager*
const tempMemoryManager = m_memoryManager;
460 const size_type tempEraseCount = m_eraseCount;
464 const size_type tempEraseTheshold = m_eraseThreshold;
478 if (m_buckets.empty())
487 if (
size_type(m_loadFactor * size()) > m_buckets.size())
494 if (m_freeEntries.empty())
496 m_freeEntries.push_back(Entry(allocate(1)));
500 Entry& newEntry = m_freeEntries.back();
501 newEntry.erased =
false;
503 FirstConstructor::construct(
504 const_cast<key_type*
>(&newEntry.value->first),
510 SecondConstructor::construct(
511 &newEntry.value->second,
517 SecondConstructor::construct(
518 &newEntry.value->second,
522 m_entries.splice(m_entries.end(), m_freeEntries, --m_freeEntries.end());
524 m_buckets[index].push_back(--m_entries.end());
534 #if defined(_MSC_VER) && _MSC_VER <= 1300
535 toRemove.value_type::~value_type();
537 toRemove.~value_type();
539 m_freeEntries.splice(
554 doRemoveEntry(begin());
561 assert(pos != end());
567 if (m_eraseCount == m_eraseThreshold)
580 assert(modulus != 0);
582 return m_hash(key) % modulus;
587 return doHash(key, m_buckets.size());
594 assert(theNewSize != 0);
604 while (entryPos != m_entries.end())
608 entryPos->value->first,
618 m_buckets.swap(temp);
626 assert(m_memoryManager != 0);
628 void* pointer = m_memoryManager->allocate(theBytesNeeded);
630 assert(pointer != 0);
632 return reinterpret_cast<value_type*
>(pointer);
638 assert(m_memoryManager != 0);
640 m_memoryManager->deallocate(pointer);
648 assert(theExtraCapacity > theCurrentSize);
655 return theCurrentSize == 0 ?
664 i != m_buckets.end();
671 while(j != theCurrentBucket.
end())
673 if ((*j)->erased ==
true)
675 j = theCurrentBucket.
erase(j);
687 theCurrentBucket.
size();
690 theCurrentBucket.
capacity() - theCurrentSize;
692 if (theExtraCapacity > theCurrentSize)
695 calculateNewBucketCapacity(
707 theCurrentBucket.
swap(theTempBucket);
745 #if defined(_MSC_VER)
755 #endif // XALANMAP_HEADER_GUARD_1357924680