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);
106template <
class Value>
114template <
class XalanMapTraits,
class BaseIterator>
119 typedef typename XalanMapTraits::pointer
pointer;
129 baseIterator(
theRhs.baseIterator)
153 return *baseIterator->value;
158 return baseIterator->value;
163 return theRhs.baseIterator == baseIterator;
168 return !(
theRhs == *
this);
236 eDefaultMinBuckets = 29u,
237 eDefaultEraseThreshold = 50u,
238 eMinimumBucketSize = 5u
263 m_loadFactor(
theRhs.m_loadFactor),
264 m_minBuckets(
theRhs.m_minBuckets),
273 m_eraseThreshold(
theRhs.m_eraseThreshold)
289 assert (m_memoryManager != 0);
291 return *m_memoryManager;
298 if (!m_buckets.empty())
302 while(
toRemove != m_freeEntries.end())
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());
364 if (!(*pos)->erased && m_equals(
key, (*pos)->value->first))
389 return (*pos).second;
395 insert(value.first, value.second);
404 doCreateEntry(
key, &data);
447 assert(m_entries.empty());
457 m_memoryManager =
theRhs.m_memoryManager;
461 m_eraseCount =
theRhs.m_eraseCount;
465 m_eraseThreshold =
theRhs.m_eraseThreshold;
468 m_entries.swap(
theRhs.m_entries);
469 m_freeEntries.swap(
theRhs.m_freeEntries);
470 m_buckets.swap(
theRhs.m_buckets);
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)));
503 FirstConstructor::construct(
510 SecondConstructor::construct(
517 SecondConstructor::construct(
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
539 m_freeEntries.splice(
554 doRemoveEntry(begin());
567 if (m_eraseCount == m_eraseThreshold)
582 return m_hash(
key) % modulus;
587 return doHash(
key, m_buckets.size());
618 m_buckets.swap(
temp);
626 assert(m_memoryManager != 0);
632 return reinterpret_cast<value_type*
>(pointer);
638 assert(m_memoryManager != 0);
640 m_memoryManager->deallocate(pointer);
664 i != m_buckets.end();
673 if ((*j)->erased ==
true)
695 calculateNewBucketCapacity(
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
size_type operator()(const Key &key) const
Xalan implementation of a hashtable.
MemoryManager * m_memoryManager
data_type & operator[](const key_type &key)
void swap(XalanMap &theRhs)
XalanMapIterator< XalanMapIteratorTraits< value_type >, typename EntryListType::iterator > iterator
KeyConstructionTraits::Constructor FirstConstructor
size_type m_eraseThreshold
const_iterator begin() const
iterator doCreateEntry(const key_type &key, const data_type *data=0)
size_type doHash(const Key &key) const
iterator find(const key_type &key)
const_iterator find(const key_type &key) const
XalanVector< BucketType, ConstructWithMemoryManagerTraits< BucketType > > BucketTableType
size_type erase(const key_type &key)
BucketTableType::iterator TableIterator
BucketType::iterator BucketIterator
std::pair< const key_type, data_type > value_type
void insert(const value_type &value)
XalanVector< typename EntryListType::iterator > BucketType
value_type * allocate(size_type size)
void insert(const key_type &key, const data_type &data)
Key key_type
Each map entry is stored in a linked list where an entry consists of a pointer to the key/value pair ...
const_iterator end() const
XalanMap(const XalanMap &theRhs, MemoryManager &theMemoryManager)
ValueConstructionTraits::Constructor SecondConstructor
void deallocate(value_type *pointer)
XalanList< Entry > EntryListType
KeyTraits::Comparator m_equals
XalanMap(MemoryManager &theMemoryManager, double loadFactor=0.75, size_type minBuckets=eDefaultMinBuckets, size_type eraseThreshold=eDefaultEraseThreshold)
XalanMapIterator< XalanMapConstIteratorTraits< value_type >, typename EntryListType::iterator > const_iterator
void doErase(iterator pos)
XalanMap & operator=(const XalanMap &theRhs)
BucketTableType m_buckets
EntryListType::iterator EntryListIterator
const size_type m_minBuckets
void doRemoveEntry(const iterator &toRemovePos)
EntryListType m_freeEntries
size_type doHash(const Key &key, size_type modulus) const
MemoryManager & getMemoryManager()
static size_type calculateNewBucketCapacity(size_type theCurrentSize, size_type theExtraCapacity)
XalanDOMString & insert(XalanDOMString &theString, XalanDOMString::size_type thePosition, const XalanDOMString &theStringToInsert)
Insert a string into another string.
void swap(XalanVector< Type > &theLHS, XalanVector< Type > &theRHS)
XalanMapTraits::reference reference
bool operator==(const XalanMapIterator &theRhs) const
XalanMapIterator(const BaseIterator &theRhs)
BaseIterator baseIterator
XalanMapTraits::pointer pointer
reference operator*() const
XalanMapIterator< XalanMapIteratorTraits< value_type >, BaseIterator > Iterator
XalanMapIterator(const Iterator &theRhs)
XalanMapTraits::value_type value_type
std::bidirectional_iterator_tag iterator_category
ptrdiff_t difference_type
pointer operator->() const
bool operator!=(const XalanMapIterator &theRhs) const
XalanMapIterator operator++(int)
XalanMapIterator & operator++()
std::equal_to< Key > Comparator
XalanHasher< Key > Hasher
Entry(value_type *theValue)