您好,欢迎来到爱站旅游。
搜索
您的当前位置:首页stl_map

stl_map

来源:爱站旅游
_hash_map.h

/* *

* Copyright (c) 1994

* Hewlett-Packard Company *

* Copyright (c) 1996,1997

* Silicon Graphics Computer Systems, Inc. *

* Copyright (c) 1997

* Moscow Center for SPARC Technology *

* Copyright (c) 1999 * Boris Fomitchev *

* This material is provided \"as is\ * or implied. Any use is at your own risk. *

* Permission to use or copy this software for any purpose is hereby granted * without fee, provided the above notices are retained on all copies.

* Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. * */

/* NOTE: This is an internal header file, included by other STL headers. * You should not attempt to use it directly. */

#ifndef _STLP_INTERNAL_HASH_MAP_H #define _STLP_INTERNAL_HASH_MAP_H

#ifndef _STLP_INTERNAL_HASHTABLE_H # include #endif

_STLP_BEGIN_NAMESPACE

//Specific iterator traits creation

_STLP_CREATE_HASH_ITERATOR_TRAITS(HashMapTraitsT, traits)

template), _STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),

_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > class hash_map

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)

: public __stlport_class> #endif {

private:

typedef hash_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; public:

typedef _Key key_type; typedef _Tp data_type; typedef _Tp mapped_type;

typedef pair<_STLP_CONST key_type, data_type> value_type; private:

//Specific iterator traits creation

typedef _STLP_PRIV _HashMapTraitsT _HashMapTraits;

public:

typedef hashtable_STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;

typedeftypename _Ht::hasher hasher;

typedeftypename _Ht::key_equal key_equal;

typedeftypename _Ht::size_type size_type;

typedeftypename _Ht::difference_type difference_type; typedeftypename _Ht::pointer pointer;

typedeftypename _Ht::const_pointer const_pointer; typedeftypename _Ht::reference reference;

typedeftypename _Ht::const_reference const_reference;

typedeftypename _Ht::iterator iterator;

typedeftypename _Ht::const_iterator const_iterator;

typedeftypename _Ht::allocator_type allocator_type;

hasher hash_funct() const { return _M_ht.hash_funct(); } key_equal key_eq() const { return _M_ht.key_eq(); }

allocator_type get_allocator() const { return _M_ht.get_allocator(); }

private:

_Ht _M_ht;

_STLP_KEY_TYPE_FOR_CONT_EXT(key_type) public:

hash_map() : _M_ht(0, hasher(), key_equal(), allocator_type()) {} explicit hash_map(size_type __n)

: _M_ht(__n, hasher(), key_equal(), allocator_type()) {} hash_map(size_type __n, const hasher& __hf)

: _M_ht(__n, __hf, key_equal(), allocator_type()) {}

hash_map(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {}

#if !defined (_STLP_NO_MOVE_SEMANTIC) hash_map(__move_source<_Self> src)

: _M_ht(__move_source<_Ht>(src.get()._M_ht)) { } #endif

#ifdef _STLP_MEMBER_TEMPLATES template

hash_map(_InputIterator __f, _InputIterator __l) : _M_ht(0, hasher(), key_equal(), allocator_type()) { _M_ht.insert_unique(__f, __l); } template

hash_map(_InputIterator __f, _InputIterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) { _M_ht.insert_unique(__f, __l); } template

hash_map(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf)

: _M_ht(__n, __hf, key_equal(), allocator_type()) { _M_ht.insert_unique(__f, __l); }

# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS template

hash_map(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf, const key_equal& __eql) : _M_ht(__n, __hf, __eql, allocator_type()) { _M_ht.insert_unique(__f, __l); } # endif

template

hash_map(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf, const key_equal& __eql,

const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) : _M_ht(__n, __hf, __eql, __a)

{ _M_ht.insert_unique(__f, __l); }

#else

hash_map(const value_type* __f, const value_type* __l) : _M_ht(0, hasher(), key_equal(), allocator_type()) { _M_ht.insert_unique(__f, __l); }

hash_map(const value_type* __f, const value_type* __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) { _M_ht.insert_unique(__f, __l); }

hash_map(const value_type* __f, const value_type* __l, size_type __n, const hasher& __hf)

: _M_ht(__n, __hf, key_equal(), allocator_type()) { _M_ht.insert_unique(__f, __l); }

hash_map(const value_type* __f, const value_type* __l, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_unique(__f, __l); }

hash_map(const_iterator __f, const_iterator __l) : _M_ht(0, hasher(), key_equal(), allocator_type()) { _M_ht.insert_unique(__f, __l); }

hash_map(const_iterator __f, const_iterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) { _M_ht.insert_unique(__f, __l); }

hash_map(const_iterator __f, const_iterator __l, size_type __n, const hasher& __hf)

: _M_ht(__n, __hf, key_equal(), allocator_type()) { _M_ht.insert_unique(__f, __l); }

hash_map(const_iterator __f, const_iterator __l, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_unique(__f, __l); }

#endif/*_STLP_MEMBER_TEMPLATES */

public:

size_type size() const { return _M_ht.size(); }

size_type max_size() const { return _M_ht.max_size(); } bool empty() const { return _M_ht.empty(); }

void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) void _M_swap_workaround(_Self& __x) { swap(__x); }

#endif

iterator begin() { return _M_ht.begin(); } iterator end() { return _M_ht.end(); }

const_iterator begin() const { return _M_ht.begin(); } const_iterator end() const { return _M_ht.end(); }

public:

pair insert(const value_type& __obj) { return _M_ht.insert_unique(__obj); } #ifdef _STLP_MEMBER_TEMPLATES template

void insert(_InputIterator __f, _InputIterator __l) { _M_ht.insert_unique(__f,__l); } #else

void insert(const value_type* __f, const value_type* __l) { _M_ht.insert_unique(__f,__l); }

void insert(const_iterator __f, const_iterator __l) { _M_ht.insert_unique(__f, __l); }

#endif/*_STLP_MEMBER_TEMPLATES */

pair insert_noresize(const value_type& __obj) { return _M_ht.insert_unique_noresize(__obj); }

_STLP_TEMPLATE_FOR_CONT_EXT

iterator find(const _KT& __key) { return _M_ht.find(__key); } _STLP_TEMPLATE_FOR_CONT_EXT

const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT _Tp&operator[](const _KT& __key) { iterator __it = _M_ht.find(__key); return (__it == _M_ht.end() ?

_M_ht._M_insert(value_type(__key,

_STLP_DEFAULT_CONSTRUCTED(_Tp))).second : (*__it).second ); }

_STLP_TEMPLATE_FOR_CONT_EXT

size_type count(const _KT& __key) const { return _M_ht.count(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __key) { return _M_ht.equal_range(__key); } _STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __key) const

{ return _M_ht.equal_range(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT

size_type erase(const _KT& __key) {return _M_ht.erase(__key); } void erase(iterator __it) { _M_ht.erase(__it); }

void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } void clear() { _M_ht.clear(); }

void resize(size_type __hint) { _M_ht.resize(__hint); }

size_type bucket_count() const { return _M_ht.bucket_count(); }

size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } size_type elems_in_bucket(size_type __n) const { return _M_ht.elems_in_bucket(__n); } };

//Specific iterator traits creation

_STLP_CREATE_HASH_ITERATOR_TRAITS(HashMultimapTraitsT, traits)

template), _STLP_DFL_TMPL_PARAM(_EqualKey,equal_to<_Key>),

_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > class hash_multimap

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)

: public __stlport_class> #endif {

private:

typedef hash_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; public:

typedef _Key key_type; typedef _Tp data_type; typedef _Tp mapped_type;

typedef pair<_STLP_CONST key_type, data_type> value_type; private:

//Specific iterator traits creation

typedef _STLP_PRIV _HashMultimapTraitsT _HashMultimapTraits;

public:

typedef hashtable_STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;

typedeftypename _Ht::hasher hasher;

typedeftypename _Ht::key_equal key_equal;

typedeftypename _Ht::size_type size_type;

typedeftypename _Ht::difference_type difference_type; typedeftypename _Ht::pointer pointer;

typedeftypename _Ht::const_pointer const_pointer; typedeftypename _Ht::reference reference;

typedeftypename _Ht::const_reference const_reference;

typedeftypename _Ht::iterator iterator;

typedeftypename _Ht::const_iterator const_iterator;

typedeftypename _Ht::allocator_type allocator_type;

hasher hash_funct() const { return _M_ht.hash_funct(); } key_equal key_eq() const { return _M_ht.key_eq(); }

allocator_type get_allocator() const { return _M_ht.get_allocator(); }

private:

_Ht _M_ht;

_STLP_KEY_TYPE_FOR_CONT_EXT(key_type) public:

hash_multimap() : _M_ht(0, hasher(), key_equal(), allocator_type()) {} explicit hash_multimap(size_type __n)

: _M_ht(__n, hasher(), key_equal(), allocator_type()) {} hash_multimap(size_type __n, const hasher& __hf) : _M_ht(__n, __hf, key_equal(), allocator_type()) {}

hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {}

#if !defined (_STLP_NO_MOVE_SEMANTIC) hash_multimap(__move_source<_Self> src)

: _M_ht(__move_source<_Ht>(src.get()._M_ht)) { } #endif

#ifdef _STLP_MEMBER_TEMPLATES template

hash_multimap(_InputIterator __f, _InputIterator __l) : _M_ht(0, hasher(), key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); } template

hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type())

{ _M_ht.insert_equal(__f, __l); } template

hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf)

: _M_ht(__n, __hf, key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); }

# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS template

hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf, const key_equal& __eql) : _M_ht(__n, __hf, __eql, allocator_type()) { _M_ht.insert_equal(__f, __l); } # endif

template

hash_multimap(_InputIterator __f, _InputIterator __l, size_type __n, const hasher& __hf, const key_equal& __eql,

const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_equal(__f, __l); }

#else

hash_multimap(const value_type* __f, const value_type* __l) : _M_ht(0, hasher(), key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); }

hash_multimap(const value_type* __f, const value_type* __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); }

hash_multimap(const value_type* __f, const value_type* __l, size_type __n, const hasher& __hf)

: _M_ht(__n, __hf, key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); }

hash_multimap(const value_type* __f, const value_type* __l, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_equal(__f, __l); }

hash_multimap(const_iterator __f, const_iterator __l) : _M_ht(0, hasher(), key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); }

hash_multimap(const_iterator __f, const_iterator __l, size_type __n) : _M_ht(__n, hasher(), key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); }

hash_multimap(const_iterator __f, const_iterator __l, size_type __n,

const hasher& __hf)

: _M_ht(__n, __hf, key_equal(), allocator_type()) { _M_ht.insert_equal(__f, __l); }

hash_multimap(const_iterator __f, const_iterator __l, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_equal(__f, __l); }

#endif/*_STLP_MEMBER_TEMPLATES */

public:

size_type size() const { return _M_ht.size(); }

size_type max_size() const { return _M_ht.max_size(); } bool empty() const { return _M_ht.empty(); }

void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) void _M_swap_workaround(_Self& __x) { swap(__x); } #endif

iterator begin() { return _M_ht.begin(); } iterator end() { return _M_ht.end(); }

const_iterator begin() const { return _M_ht.begin(); } const_iterator end() const { return _M_ht.end(); }

public:

iterator insert(const value_type& __obj) { return _M_ht.insert_equal(__obj); } #ifdef _STLP_MEMBER_TEMPLATES template

void insert(_InputIterator __f, _InputIterator __l) { _M_ht.insert_equal(__f,__l); } #else

void insert(const value_type* __f, const value_type* __l) { _M_ht.insert_equal(__f,__l); }

void insert(const_iterator __f, const_iterator __l) { _M_ht.insert_equal(__f, __l); }

#endif/*_STLP_MEMBER_TEMPLATES */

iterator insert_noresize(const value_type& __obj) { return _M_ht.insert_equal_noresize(__obj); }

_STLP_TEMPLATE_FOR_CONT_EXT

iterator find(const _KT& __key) { return _M_ht.find(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT

const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT

size_type count(const _KT& __key) const { return _M_ht.count(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT pair

equal_range(const _KT& __key) { return _M_ht.equal_range(__key); } _STLP_TEMPLATE_FOR_CONT_EXT pair

equal_range(const _KT& __key) const { return _M_ht.equal_range(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT

size_type erase(const _KT& __key) {return _M_ht.erase(__key); } void erase(iterator __it) { _M_ht.erase(__it); }

void erase(iterator __f, iterator __l) { _M_ht.erase(__f, __l); } void clear() { _M_ht.clear(); }

public:

void resize(size_type __hint) { _M_ht.resize(__hint); }

size_type bucket_count() const { return _M_ht.bucket_count(); }

size_type max_bucket_count() const { return _M_ht.max_bucket_count(); } size_type elems_in_bucket(size_type __n) const { return _M_ht.elems_in_bucket(__n); } };

#define _STLP_TEMPLATE_HEADER template

#define _STLP_TEMPLATE_CONTAINER hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc> #include

#undef _STLP_TEMPLATE_CONTAINER #define _STLP_TEMPLATE_CONTAINER

hash_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc> #include

#undef _STLP_TEMPLATE_CONTAINER #undef _STLP_TEMPLATE_HEADER

#ifdefined (_STLP_CLASS_PARTIAL_SPECIALIZATION) # if !defined (_STLP_NO_MOVE_SEMANTIC)

template struct __move_traits> :

_STLP_PRIV __move_traits_help::_Ht>

{};

template struct __move_traits> :

_STLP_PRIV __move_traits_help::_Ht> {};

# endif

// Specialization of insert_iterator so that it will work for hash_map // and hash_multimap.

template class insert_iterator> { protected:

typedef hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; _Container* container; public:

typedef _Container container_type; typedef output_iterator_tag iterator_category; typedefvoid value_type; typedefvoid difference_type; typedefvoid pointer; typedefvoid reference;

insert_iterator(_Container& __x) : container(&__x) {}

insert_iterator(_Container& __x, typename _Container::iterator) : container(&__x) {}

insert_iterator<_Container>&

operator=(consttypename _Container::value_type& __val) { container->insert(__val); return *this; }

insert_iterator<_Container>&operator*() { return *this; } insert_iterator<_Container>&operator++() { return *this; } insert_iterator<_Container>&operator++(int) { return *this; } };

template class insert_iterator> { protected:

typedef hash_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; _Container* container;

typename _Container::iterator iter; public:

typedef _Container container_type; typedef output_iterator_tag iterator_category; typedefvoid value_type; typedefvoid difference_type; typedefvoid pointer; typedefvoid reference;

insert_iterator(_Container& __x) : container(&__x) {}

insert_iterator(_Container& __x, typename _Container::iterator) : container(&__x) {}

insert_iterator<_Container>&

operator=(consttypename _Container::value_type& __val) { container->insert(__val); return *this; }

insert_iterator<_Container>&operator*() { return *this; } insert_iterator<_Container>&operator++() { return *this; } insert_iterator<_Container>&operator++(int) { return *this; } };

#endif/* _STLP_CLASS_PARTIAL_SPECIALIZATION */

_STLP_END_NAMESPACE

#endif/* _STLP_INTERNAL_HASH_MAP_H */

// Local Variables: // mode:C++ // End:

_map.h

/* *

* Copyright (c) 1994

* Hewlett-Packard Company *

* Copyright (c) 1996,1997

* Silicon Graphics Computer Systems, Inc. *

* Copyright (c) 1997

* Moscow Center for SPARC Technology *

* Copyright (c) 1999 * Boris Fomitchev *

* This material is provided \"as is\ * or implied. Any use is at your own risk. *

* Permission to use or copy this software for any purpose is hereby granted * without fee, provided the above notices are retained on all copies.

* Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. * */

/* NOTE: This is an internal header file, included by other STL headers. * You should not attempt to use it directly. */

#ifndef _STLP_INTERNAL_MAP_H #define _STLP_INTERNAL_MAP_H

#ifndef _STLP_INTERNAL_TREE_H # include #endif

_STLP_BEGIN_NAMESPACE

//Specific iterator traits creation

_STLP_CREATE_ITERATOR_TRAITS(MapTraitsT, traits)

template ),

_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > class map

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)

: public __stlport_class> #endif {

typedef map<_Key, _Tp, _Compare, _Alloc> _Self; public:

// typedefs:

typedef _Key key_type; typedef _Tp data_type;

typedef _Tp mapped_type; typedef pair<_STLP_CONST _Key, _Tp> value_type; typedef _Compare key_compare;

class value_compare

: public binary_function { friendclass map<_Key,_Tp,_Compare,_Alloc>; protected :

//c is a Standard name (23.3.1), do no make it STLport naming convention compliant. _Compare comp;

value_compare(_Compare __c) : comp(__c) {} public:

booloperator()(const value_type& __x, const value_type& __y) const { return comp(__x.first, __y.first); } };

protected:

typedef _STLP_PRIV _MapTraitsT _MapTraits;

public:

//Following typedef have to be public for __move_traits specialization. typedef _STLP_PRIV _Rb_tree value_type, _STLP_SELECT1ST(value_type, _Key), _MapTraits, _Alloc> _Rep_type;

typedeftypename _Rep_type::pointer pointer;

typedeftypename _Rep_type::const_pointer const_pointer; typedeftypename _Rep_type::reference reference;

typedeftypename _Rep_type::const_reference const_reference; typedeftypename _Rep_type::iterator iterator;

typedeftypename _Rep_type::const_iterator const_iterator; typedeftypename _Rep_type::reverse_iterator reverse_iterator;

typedeftypename _Rep_type::const_reverse_iterator const_reverse_iterator; typedeftypename _Rep_type::size_type size_type;

typedeftypename _Rep_type::difference_type difference_type; typedeftypename _Rep_type::allocator_type allocator_type;

private:

_Rep_type _M_t; // red-black tree representing map _STLP_KEY_TYPE_FOR_CONT_EXT(key_type)

public:

// allocation/deallocation

map() : _M_t(_Compare(), allocator_type()) {}

#if !defined (_STLP_DONT_SUP_DFLT_PARAM) explicit map(const _Compare& __comp, const allocator_type& __a = allocator_type()) #else

explicit map(const _Compare& __comp) : _M_t(__comp, allocator_type()) {}

explicit map(const _Compare& __comp, const allocator_type& __a) #endif

: _M_t(__comp, __a) {}

#ifdefined (_STLP_MEMBER_TEMPLATES) template

map(_InputIterator __first, _InputIterator __last) : _M_t(_Compare(), allocator_type()) { _M_t.insert_unique(__first, __last); }

template

map(_InputIterator __first, _InputIterator __last, const _Compare& __comp, const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }

# ifdefined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS) template

map(_InputIterator __first, _InputIterator __last, const _Compare& __comp) : _M_t(__comp, allocator_type()) { _M_t.insert_unique(__first, __last); } # endif

#else

map(const value_type* __first, const value_type* __last) : _M_t(_Compare(), allocator_type()) { _M_t.insert_unique(__first, __last); }

map(const value_type* __first,

const value_type* __last, const _Compare& __comp, const allocator_type& __a = allocator_type())

: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }

map(const_iterator __first, const_iterator __last) : _M_t(_Compare(), allocator_type()) { _M_t.insert_unique(__first, __last); }

map(const_iterator __first, const_iterator __last, const _Compare& __comp, const allocator_type& __a = allocator_type())

: _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }

#endif/* _STLP_MEMBER_TEMPLATES */

map(const _Self& __x) : _M_t(__x._M_t) {}

#if !defined (_STLP_NO_MOVE_SEMANTIC) map(__move_source<_Self> src)

: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} #endif

_Self&operator=(const _Self& __x) { _M_t = __x._M_t; return *this; }

// accessors:

key_compare key_comp() const { return _M_t.key_comp(); }

value_compare value_comp() const { return value_compare(_M_t.key_comp()); } allocator_type get_allocator() const { return _M_t.get_allocator(); }

iterator begin() { return _M_t.begin(); }

const_iterator begin() const { return _M_t.begin(); } iterator end() { return _M_t.end(); }

const_iterator end() const { return _M_t.end(); } reverse_iterator rbegin() { return _M_t.rbegin(); }

const_reverse_iterator rbegin() const { return _M_t.rbegin(); } reverse_iterator rend() { return _M_t.rend(); }

const_reverse_iterator rend() const { return _M_t.rend(); } bool empty() const { return _M_t.empty(); } size_type size() const { return _M_t.size(); }

size_type max_size() const { return _M_t.max_size(); } _STLP_TEMPLATE_FOR_CONT_EXT _Tp&operator[](const _KT& __k) { iterator __i = lower_bound(__k);

// __i->first is greater than or equivalent to __k. if (__i == end() || key_comp()(__k, (*__i).first))

__i = insert(__i, value_type(__k, _STLP_DEFAULT_CONSTRUCTED(_Tp))); return (*__i).second; }

void swap(_Self& __x) { _M_t.swap(__x._M_t); }

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) void _M_swap_workaround(_Self& __x) { swap(__x); } #endif

// insert/erase

pair insert(const value_type& __x) { return _M_t.insert_unique(__x); }

iterator insert(iterator __pos, const value_type& __x) { return _M_t.insert_unique(__pos, __x); } #ifdef _STLP_MEMBER_TEMPLATES template

void insert(_InputIterator __first, _InputIterator __last) { _M_t.insert_unique(__first, __last); } #else

void insert(const value_type* __first, const value_type* __last) { _M_t.insert_unique(__first, __last); }

void insert(const_iterator __first, const_iterator __last) { _M_t.insert_unique(__first, __last); } #endif/* _STLP_MEMBER_TEMPLATES */

void erase(iterator __pos) { _M_t.erase(__pos); }

size_type erase(const key_type& __x) { return _M_t.erase_unique(__x); } void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); } void clear() { _M_t.clear(); }

// map operations:

_STLP_TEMPLATE_FOR_CONT_EXT

iterator find(const _KT& __x) { return _M_t.find(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

const_iterator find(const _KT& __x) const { return _M_t.find(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

size_type count(const _KT& __x) const { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } _STLP_TEMPLATE_FOR_CONT_EXT

iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); }

_STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __x) { return _M_t.equal_range_unique(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __x) const { return _M_t.equal_range_unique(__x); } };

//Specific iterator traits creation

_STLP_CREATE_ITERATOR_TRAITS(MultimapTraitsT, traits)

template ),

_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > class multimap

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)

: public __stlport_class> #endif {

typedef multimap<_Key, _Tp, _Compare, _Alloc> _Self; public:

// typedefs:

typedef _Key key_type; typedef _Tp data_type; typedef _Tp mapped_type; typedef pair<_STLP_CONST _Key, _Tp> value_type; typedef _Compare key_compare;

class value_compare : public binary_function { friendclass multimap<_Key,_Tp,_Compare,_Alloc>; protected:

//comp is a Standard name (23.3.2), do no make it STLport naming convention compliant. _Compare comp;

value_compare(_Compare __c) : comp(__c) {} public:

booloperator()(const value_type& __x, const value_type& __y) const { return comp(__x.first, __y.first); } };

protected:

//Specific iterator traits creation

typedef _STLP_PRIV _MultimapTraitsT _MultimapTraits;

public:

//Following typedef have to be public for __move_traits specialization. typedef _STLP_PRIV _Rb_tree value_type, _STLP_SELECT1ST(value_type, _Key), _MultimapTraits, _Alloc> _Rep_type;

typedeftypename _Rep_type::pointer pointer;

typedeftypename _Rep_type::const_pointer const_pointer; typedeftypename _Rep_type::reference reference;

typedeftypename _Rep_type::const_reference const_reference; typedeftypename _Rep_type::iterator iterator;

typedeftypename _Rep_type::const_iterator const_iterator; typedeftypename _Rep_type::reverse_iterator reverse_iterator;

typedeftypename _Rep_type::const_reverse_iterator const_reverse_iterator; typedeftypename _Rep_type::size_type size_type;

typedeftypename _Rep_type::difference_type difference_type; typedeftypename _Rep_type::allocator_type allocator_type;

private:

_Rep_type _M_t; // red-black tree representing multimap _STLP_KEY_TYPE_FOR_CONT_EXT(key_type)

public:

// allocation/deallocation

multimap() : _M_t(_Compare(), allocator_type()) { } explicit multimap(const _Compare& __comp, const allocator_type& __a = allocator_type()) : _M_t(__comp, __a) { }

#ifdef _STLP_MEMBER_TEMPLATES template

multimap(_InputIterator __first, _InputIterator __last) : _M_t(_Compare(), allocator_type()) { _M_t.insert_equal(__first, __last); }

# ifdef _STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS template

multimap(_InputIterator __first, _InputIterator __last, const _Compare& __comp)

: _M_t(__comp, allocator_type()) { _M_t.insert_equal(__first, __last); } # endif

template

multimap(_InputIterator __first, _InputIterator __last, const _Compare& __comp,

const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL) : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } #else

multimap(const value_type* __first, const value_type* __last) : _M_t(_Compare(), allocator_type()) { _M_t.insert_equal(__first, __last); }

multimap(const value_type* __first, const value_type* __last, const _Compare& __comp,

const allocator_type& __a = allocator_type())

: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }

multimap(const_iterator __first, const_iterator __last) : _M_t(_Compare(), allocator_type()) { _M_t.insert_equal(__first, __last); }

multimap(const_iterator __first, const_iterator __last, const _Compare& __comp,

const allocator_type& __a = allocator_type())

: _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); } #endif/* _STLP_MEMBER_TEMPLATES */

multimap(const _Self& __x) : _M_t(__x._M_t) {}

#if !defined (_STLP_NO_MOVE_SEMANTIC) multimap(__move_source<_Self> src)

: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {} #endif

_Self&operator=(const _Self& __x) { _M_t = __x._M_t; return *this; }

// accessors:

key_compare key_comp() const { return _M_t.key_comp(); }

value_compare value_comp() const { return value_compare(_M_t.key_comp()); } allocator_type get_allocator() const { return _M_t.get_allocator(); }

iterator begin() { return _M_t.begin(); }

const_iterator begin() const { return _M_t.begin(); } iterator end() { return _M_t.end(); }

const_iterator end() const { return _M_t.end(); } reverse_iterator rbegin() { return _M_t.rbegin(); }

const_reverse_iterator rbegin() const { return _M_t.rbegin(); } reverse_iterator rend() { return _M_t.rend(); }

const_reverse_iterator rend() const { return _M_t.rend(); } bool empty() const { return _M_t.empty(); } size_type size() const { return _M_t.size(); }

size_type max_size() const { return _M_t.max_size(); } void swap(_Self& __x) { _M_t.swap(__x._M_t); }

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)

void _M_swap_workaround(_Self& __x) { swap(__x); } #endif

// insert/erase

iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); }

iterator insert(iterator __pos, const value_type& __x) { return _M_t.insert_equal(__pos, __x); } #ifdefined (_STLP_MEMBER_TEMPLATES) template

void insert(_InputIterator __first, _InputIterator __last) { _M_t.insert_equal(__first, __last); } #else

void insert(const value_type* __first, const value_type* __last) { _M_t.insert_equal(__first, __last); }

void insert(const_iterator __first, const_iterator __last) { _M_t.insert_equal(__first, __last); }

#endif/* _STLP_MEMBER_TEMPLATES */ void erase(iterator __pos) { _M_t.erase(__pos); }

size_type erase(const key_type& __x) { return _M_t.erase(__x); } void erase(iterator __first, iterator __last) { _M_t.erase(__first, __last); } void clear() { _M_t.clear(); }

// multimap operations:

_STLP_TEMPLATE_FOR_CONT_EXT

iterator find(const _KT& __x) { return _M_t.find(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

const_iterator find(const _KT& __x) const { return _M_t.find(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

size_type count(const _KT& __x) const { return _M_t.count(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

iterator lower_bound(const _KT& __x) { return _M_t.lower_bound(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

const_iterator lower_bound(const _KT& __x) const { return _M_t.lower_bound(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

iterator upper_bound(const _KT& __x) { return _M_t.upper_bound(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

const_iterator upper_bound(const _KT& __x) const { return _M_t.upper_bound(__x); } _STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __x) { return _M_t.equal_range(__x); }

_STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __x) const { return _M_t.equal_range(__x); } };

#define _STLP_TEMPLATE_HEADER template

#define _STLP_TEMPLATE_CONTAINER map<_Key,_Tp,_Compare,_Alloc> #include

#undef _STLP_TEMPLATE_CONTAINER

#define _STLP_TEMPLATE_CONTAINER multimap<_Key,_Tp,_Compare,_Alloc> #include

#undef _STLP_TEMPLATE_CONTAINER #undef _STLP_TEMPLATE_HEADER

#ifdefined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (_STLP_NO_MOVE_SEMANTIC)

template struct __move_traits> :

_STLP_PRIV __move_traits_aux::_Rep_type> {};

template struct __move_traits> : _STLP_PRIV __move_traits_auxmultimap<_Key,_Tp,_Compare,_Alloc>::_Rep_type> {}; #endif

_STLP_END_NAMESPACE

#endif/* _STLP_INTERNAL_MAP_H */

// Local Variables: // mode:C++ // End:

_unordered_map.h

/*

* Copyright (c) 2004 * Francois Dumont *

* This material is provided \"as is\ * or implied. Any use is at your own risk. *

* Permission to use or copy this software for any purpose is hereby granted

* without fee, provided the above notices are retained on all copies.

* Permission to modify the code and to distribute modified code is granted, * provided the above notices are retained, and a notice that the code was * modified is included with the above copyright notice. * */

/* NOTE: This is an internal header file, included by other STL headers. * You should not attempt to use it directly. */

#ifndef _STLP_INTERNAL_UNORDERED_MAP_H #define _STLP_INTERNAL_UNORDERED_MAP_H

#ifndef _STLP_INTERNAL_HASHTABLE_H # include #endif

_STLP_BEGIN_NAMESPACE

//Specific iterator traits creation

_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedMapTraitsT, traits)

_STLP_BEGIN_TR1_NAMESPACE

template), _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Key>),

_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > class unordered_map

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)

: public __stlport_class> #endif {

private:

typedef unordered_map<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; public:

typedef _Key key_type; typedef _Tp data_type; typedef _Tp mapped_type;

typedef pair<_STLP_CONST key_type, data_type> value_type; private:

//Specific iterator traits creation

typedef _STLP_PRIV _UnorderedMapTraitsT _UnorderedMapTraits;

public:

typedef hashtable_STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;

typedeftypename _Ht::hasher hasher;

typedeftypename _Ht::key_equal key_equal;

typedeftypename _Ht::size_type size_type;

typedeftypename _Ht::difference_type difference_type; typedeftypename _Ht::pointer pointer;

typedeftypename _Ht::const_pointer const_pointer; typedeftypename _Ht::reference reference;

typedeftypename _Ht::const_reference const_reference;

typedeftypename _Ht::iterator iterator;

typedeftypename _Ht::const_iterator const_iterator; typedeftypename _Ht::local_iterator local_iterator;

typedeftypename _Ht::const_local_iterator const_local_iterator;

typedeftypename _Ht::allocator_type allocator_type;

hasher hash_function() const { return _M_ht.hash_funct(); } key_equal key_eq() const { return _M_ht.key_eq(); }

allocator_type get_allocator() const { return _M_ht.get_allocator(); }

private:

_Ht _M_ht;

_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)

public:

explicit unordered_map(size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),

const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {}

#if !defined (_STLP_NO_MOVE_SEMANTIC) unordered_map(__move_source<_Self> src)

: _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} #endif

#ifdefined (_STLP_MEMBER_TEMPLATES) template

unordered_map(_InputIterator __f, _InputIterator __l,

size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),

const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_unique(__f, __l); } #else

unordered_map(const value_type* __f, const value_type* __l,

size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),

const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_unique(__f, __l); }

unordered_map(const_iterator __f, const_iterator __l,

size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),

const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_unique(__f, __l); }

#endif/*_STLP_MEMBER_TEMPLATES */

_Self&operator = (const _Self& __other) { _M_ht = __other._M_ht; return *this; }

size_type size() const { return _M_ht.size(); }

size_type max_size() const { return _M_ht.max_size(); } bool empty() const { return _M_ht.empty(); }

void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) void _M_swap_workaround(_Self& __x) { swap(__x); } #endif

iterator begin() { return _M_ht.begin(); } iterator end() { return _M_ht.end(); }

const_iterator begin() const { return _M_ht.begin(); } const_iterator end() const { return _M_ht.end(); }

pair insert(const value_type& __obj) { return _M_ht.insert_unique(__obj); }

iterator insert(const_iterator /*__hint*/, const value_type& __obj) { return _M_ht.insert_unique(__obj); }

#ifdefined (_STLP_MEMBER_TEMPLATES) template

void insert(_InputIterator __f, _InputIterator __l) #else

void insert(const value_type* __f, const value_type* __l) { _M_ht.insert_unique(__f,__l); }

void insert(const_iterator __f, const_iterator __l) #endif/*_STLP_MEMBER_TEMPLATES */ { _M_ht.insert_unique(__f, __l); }

_STLP_TEMPLATE_FOR_CONT_EXT

iterator find(const _KT& __key) { return _M_ht.find(__key); } _STLP_TEMPLATE_FOR_CONT_EXT

const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT _Tp&operator[](const _KT& __key) { iterator __it = _M_ht.find(__key); return (__it == _M_ht.end() ?

_M_ht._M_insert(value_type(__key,

_STLP_DEFAULT_CONSTRUCTED(_Tp))).second : (*__it).second ); }

_STLP_TEMPLATE_FOR_CONT_EXT

size_type count(const _KT& __key) const { return _M_ht.count(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __key) { return _M_ht.equal_range(__key); } _STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __key) const { return _M_ht.equal_range(__key); }

size_type erase(const key_type& __key) {return _M_ht.erase(__key); } void erase(const_iterator __it) { _M_ht.erase(__it); }

void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); } void clear() { _M_ht.clear(); }

size_type bucket_count() const { return _M_ht.bucket_count(); }

size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }

size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); } _STLP_TEMPLATE_FOR_CONT_EXT

size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); } local_iterator begin(size_type __n) { return _M_ht.begin(__n); } local_iterator end(size_type __n) { return _M_ht.end(__n); }

const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); } const_local_iterator end(size_type __n) const { return _M_ht.end(__n); }

float load_factor() const { return _M_ht.load_factor(); }

float max_load_factor() const { return _M_ht.max_load_factor(); } void max_load_factor(float __val) { _M_ht.max_load_factor(__val); } void rehash(size_type __hint) { _M_ht.rehash(__hint); }

#ifdefined (__DMC__) // disable operator==(pair, pair) booloperator==(const _Self&) const; #endif };

_STLP_END_NAMESPACE

//Specific iterator traits creation

_STLP_CREATE_HASH_ITERATOR_TRAITS(UnorderedMultimapTraitsT, traits)

_STLP_BEGIN_TR1_NAMESPACE

template), _STLP_DFL_TMPL_PARAM(_EqualKey, equal_to<_Key>),

_STLP_DEFAULT_PAIR_ALLOCATOR_SELECT(_STLP_CONST _Key, _Tp) > class unordered_multimap

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)

: public __stlport_class> #endif {

private:

typedef unordered_multimap<_Key, _Tp, _HashFcn, _EqualKey, _Alloc> _Self; public:

typedef _Key key_type; typedef _Tp data_type; typedef _Tp mapped_type;

typedef pair<_STLP_CONST key_type, data_type> value_type; private:

//Specific iterator traits creation

typedef _STLP_PRIV _UnorderedMultimapTraitsT _UnorderedMultimapTraits;

public:

typedef hashtable_STLP_SELECT1ST(value_type, _Key), _EqualKey, _Alloc > _Ht;

typedeftypename _Ht::hasher hasher;

typedeftypename _Ht::key_equal key_equal;

typedeftypename _Ht::size_type size_type;

typedeftypename _Ht::difference_type difference_type; typedeftypename _Ht::pointer pointer;

typedeftypename _Ht::const_pointer const_pointer; typedeftypename _Ht::reference reference;

typedeftypename _Ht::const_reference const_reference;

typedeftypename _Ht::iterator iterator;

typedeftypename _Ht::const_iterator const_iterator; typedeftypename _Ht::local_iterator local_iterator;

typedeftypename _Ht::const_local_iterator const_local_iterator;

typedeftypename _Ht::allocator_type allocator_type;

hasher hash_function() const { return _M_ht.hash_funct(); } key_equal key_eq() const { return _M_ht.key_eq(); }

allocator_type get_allocator() const { return _M_ht.get_allocator(); }

private:

_Ht _M_ht;

_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)

public:

explicit unordered_multimap(size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),

const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) {}

#if !defined (_STLP_NO_MOVE_SEMANTIC) unordered_multimap(__move_source<_Self> src) : _M_ht(__move_source<_Ht>(src.get()._M_ht)) {} #endif

#ifdefined (_STLP_MEMBER_TEMPLATES) template

unordered_multimap(_InputIterator __f, _InputIterator __l,

size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),

const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_equal(__f, __l); }

#else

unordered_multimap(const value_type* __f, const value_type* __l,

size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),

const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_equal(__f, __l); }

unordered_multimap(const_iterator __f, const_iterator __l,

size_type __n = 0, const hasher& __hf = hasher(), const key_equal& __eql = key_equal(),

const allocator_type& __a = allocator_type()) : _M_ht(__n, __hf, __eql, __a) { _M_ht.insert_equal(__f, __l); }

#endif/*_STLP_MEMBER_TEMPLATES */

_Self&operator = (const _Self& __other) { _M_ht = __other._M_ht; return *this; }

size_type size() const { return _M_ht.size(); }

size_type max_size() const { return _M_ht.max_size(); } bool empty() const { return _M_ht.empty(); }

void swap(_Self& __hs) { _M_ht.swap(__hs._M_ht); }

#ifdefined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER) void _M_swap_workaround(_Self& __x) { swap(__x); } #endif

iterator begin() { return _M_ht.begin(); } iterator end() { return _M_ht.end(); }

const_iterator begin() const { return _M_ht.begin(); } const_iterator end() const { return _M_ht.end(); }

iterator insert(const value_type& __obj) { return _M_ht.insert_equal(__obj); }

iterator insert(const_iterator /*__hint*/, const value_type& __obj) { return _M_ht.insert_equal(__obj); }

#ifdefined (_STLP_MEMBER_TEMPLATES) template

void insert(_InputIterator __f, _InputIterator __l) #else

void insert(const value_type* __f, const value_type* __l) { _M_ht.insert_equal(__f,__l); }

void insert(const_iterator __f, const_iterator __l)

#endif/*_STLP_MEMBER_TEMPLATES */ { _M_ht.insert_equal(__f, __l); }

_STLP_TEMPLATE_FOR_CONT_EXT

iterator find(const _KT& __key) { return _M_ht.find(__key); } _STLP_TEMPLATE_FOR_CONT_EXT

const_iterator find(const _KT& __key) const { return _M_ht.find(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT

size_type count(const _KT& __key) const { return _M_ht.count(__key); }

_STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __key) { return _M_ht.equal_range(__key); } _STLP_TEMPLATE_FOR_CONT_EXT

pair equal_range(const _KT& __key) const { return _M_ht.equal_range(__key); }

size_type erase(const key_type& __key) {return _M_ht.erase(__key); } void erase(const_iterator __it) { _M_ht.erase(__it); }

void erase(const_iterator __f, const_iterator __l) { _M_ht.erase(__f, __l); } void clear() { _M_ht.clear(); }

size_type bucket_count() const { return _M_ht.bucket_count(); }

size_type max_bucket_count() const { return _M_ht.max_bucket_count(); }

size_type bucket_size(size_type __n) const { return _M_ht.elems_in_bucket(__n); } _STLP_TEMPLATE_FOR_CONT_EXT

size_type bucket(const _KT& __k) const { return _M_ht.bucket(__k); } local_iterator begin(size_type __n) { return _M_ht.begin(__n); } local_iterator end(size_type __n) { return _M_ht.end(__n); }

const_local_iterator begin(size_type __n) const { return _M_ht.begin(__n); } const_local_iterator end(size_type __n) const { return _M_ht.end(__n); }

float load_factor() const { return _M_ht.load_factor(); }

float max_load_factor() const { return _M_ht.max_load_factor(); } void max_load_factor(float __val) { _M_ht.max_load_factor(__val); } void rehash(size_type __hint) { _M_ht.rehash(__hint); } };

#define _STLP_TEMPLATE_HEADER template

#define _STLP_TEMPLATE_CONTAINER

unordered_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>

#include

#undef _STLP_TEMPLATE_CONTAINER #define _STLP_TEMPLATE_CONTAINER

unordered_multimap<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>

#include

#undef _STLP_TEMPLATE_CONTAINER #undef _STLP_TEMPLATE_HEADER

_STLP_END_NAMESPACE

// Specialization of insert_iterator so that it will work for unordered_map // and unordered_multimap.

#ifdefined (_STLP_CLASS_PARTIAL_SPECIALIZATION) # if !defined (_STLP_NO_MOVE_SEMANTIC)

template

struct __move_traits<_STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>> : _STLP_PRIV __move_traits_help::_Ht> {};

template

struct __move_traits<_STLP_TR1 unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc>> :

_STLP_PRIV __move_traits_help::_Ht> {};

# endif

template

class insert_iterator<_STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>> { protected:

typedef _STLP_TR1 unordered_map<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; _Container* container; public:

typedef _Container container_type; typedef output_iterator_tag iterator_category; typedefvoid value_type; typedefvoid difference_type; typedefvoid pointer; typedefvoid reference;

insert_iterator(_Container& __x) : container(&__x) {}

insert_iterator(_Container& __x, typename _Container::iterator) : container(&__x) {}

insert_iterator<_Container>&

operator=(consttypename _Container::value_type& __val) { container->insert(__val); return *this; }

insert_iterator<_Container>&operator*() { return *this; } insert_iterator<_Container>&operator++() { return *this; } insert_iterator<_Container>&operator++(int) { return *this; } };

template

class insert_iterator<_STLP_TR1 unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc>> {

protected:

typedef _STLP_TR1 unordered_multimap<_Key, _Tp, _HashFn, _EqKey, _Alloc> _Container; _Container* container;

typename _Container::iterator iter; public:

typedef _Container container_type; typedef output_iterator_tag iterator_category; typedefvoid value_type; typedefvoid difference_type; typedefvoid pointer; typedefvoid reference;

insert_iterator(_Container& __x) : container(&__x) {}

insert_iterator(_Container& __x, typename _Container::iterator) : container(&__x) {}

insert_iterator<_Container>&

operator=(consttypename _Container::value_type& __val) { container->insert(__val); return *this; }

insert_iterator<_Container>&operator*() { return *this; } insert_iterator<_Container>&operator++() { return *this; } insert_iterator<_Container>&operator++(int) { return *this; } };

#endif/* _STLP_CLASS_PARTIAL_SPECIALIZATION */

_STLP_END_NAMESPACE

#endif/* _STLP_INTERNAL_UNORDERED_MAP_H */

// Local Variables: // mode:C++ // End:

test_map.cpp

/***********************************************************************************

test_map.cpp

* Copyright (c) 1997

* Mark of the Unicorn, Inc. *

* Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Mark of the Unicorn makes no * representations about the suitability of this software for any

* purpose. It is provided \"as is\" without express or implied warranty.

***********************************************************************************/

#include\"Tests.h\" #include\"TestClass.h\" #include\"LeakCheck.h\"

# ifdefined (EH_NEW_HEADERS) #include # else

#include #include # endif

#include\"test_construct.h\" #include\"test_assign_op.h\" #include\"test_push_back.h\" #include\"test_insert.h\"

#include\"test_push_front.h\" #include\"ThrowCompare.h\"

#include\"test_insert.h\"

template inline multimap_tag

container_category(const EH_STD::__multimap__&) {

return multimap_tag(); }

template inline map_tag

container_category(const EH_STD::__map__&) {

return map_tag(); }

typedef EH_STD::__multimap__ TestMultiMap;

void test_multimap() {

TestMultiMap testMultiMap, testMultiMap2;

const size_t mapSize = random_number(random_base);

while ( testMultiMap.size() < mapSize ) {

TestMultiMap::value_type x; testMultiMap.insert( x );

testMultiMap2.insert( TestMultiMap::value_type() ); }

StrongCheck( testMultiMap, test_insert_value(testMultiMap) );

size_t insCnt = 1 + random_number(random_base);

TestMultiMap::value_type *insFirst = new TestMultiMap::value_type[insCnt];

WeakCheck( testMultiMap, insert_range_tester(testMultiMap, insFirst, insFirst+insCnt) );

ConstCheck( 0, test_construct_pointer_range(insFirst, insFirst+insCnt) ); delete[] insFirst;

WeakCheck( testMultiMap, insert_range_tester(testMultiMap, testMultiMap2.begin(),

testMultiMap2.end() ) );

ConstCheck( 0, test_default_construct() );

ConstCheck( 0, test_construct_iter_range( testMultiMap2 ) );

ConstCheck( testMultiMap, test_copy_construct() );

WeakCheck( testMultiMap, test_assign_op( testMultiMap2 ) ); }

typedef EH_STD::__map__ TestMap;

void CheckInvariant( const TestMap& m );

void CheckInvariant( const TestMap& m ) {

// assert( map.__rb_verify() ); size_t total = 0;

EH_DISTANCE( m.begin(), m.end(), total ); assert( m.size() == total ); }

void test_map() {

TestMap testMap, testMap2;

const size_t mapSize = random_number(random_base);

while ( testMap.size() < mapSize ) {

TestMap::value_type x; testMap.insert( x );

testMap2.insert( TestMap::value_type() ); }

StrongCheck( testMap, test_insert_value(testMap) );

size_t insCnt = random_number(random_base);

TestMap::value_type *insFirst = new TestMap::value_type[1+insCnt];

WeakCheck( testMap, insert_range_tester(testMap, insFirst, insFirst+insCnt) );

ConstCheck( 0, test_construct_pointer_range(insFirst, insFirst+insCnt) ); delete[] insFirst;

WeakCheck( testMap, insert_range_tester(testMap, testMap2.begin(), testMap2.end() ) ); ConstCheck( 0, test_default_construct() );

ConstCheck( 0, test_construct_iter_range( testMap2 ) ); ConstCheck( testMap, test_copy_construct() );

WeakCheck( testMap, test_assign_op( testMap2 ) ); }

map_header_test.cpp

/* This test purpose is simply to check Standard header independancy that * is to say that the header can be included alone without any previous * include.

* Additionnaly, for C Standard headers that STLport expose, it can also be * used to check that files included by those headers are compatible with * pure C compilers. */

#include

map_test.cpp

//Has to be first for StackAllocator swap overload to be taken //into account (at least using GCC 4.0.1) #include\"stack_allocator.h\"

#include

#include

#include\"cppunit/cppunit_proxy.h\"

#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES) usingnamespace std; #endif //

// TestCase class //

class MapTest : public CPPUNIT_NS::TestCase {

CPPUNIT_TEST_SUITE(MapTest); CPPUNIT_TEST(map1); CPPUNIT_TEST(mmap1); CPPUNIT_TEST(mmap2); CPPUNIT_TEST(iterators); CPPUNIT_TEST(equal_range);

CPPUNIT_TEST(allocator_with_state);

#if !defined (STLPORT) || !defined (_STLP_USE_CONTAINERS_EXTENSION) CPPUNIT_IGNORE; #endif

CPPUNIT_TEST(template_methods); CPPUNIT_TEST_SUITE_END();

protected: void map1(); void mmap1(); void mmap2(); void iterators(); void equal_range();

void allocator_with_state(); void template_methods(); };

CPPUNIT_TEST_SUITE_REGISTRATION(MapTest); //

// tests implementation //

void MapTest::map1() {

typedef map> maptype; maptype m;

// Store mappings between roman numerals and decimals. m['l'] = 50;

m['x'] = 20; // Deliberate mistake. m['v'] = 5; m['i'] = 1;

// cout << \"m['x'] = \" << m['x'] << endl; CPPUNIT_ASSERT( m['x']== 20 ); m['x'] = 10; // Correct mistake.

CPPUNIT_ASSERT( m['x']== 10 ); CPPUNIT_ASSERT( m['z']== 0 );

//cout << \"m['z'] = \" << m['z'] << endl; // Note default value is added. CPPUNIT_ASSERT( m.count('z') == 1 );

//cout << \"m.count('z') = \" << m.count('z') << endl;

pair p = m.insert(pair('c', 100)); CPPUNIT_ASSERT( p.second );

CPPUNIT_ASSERT( p.first != m.end() ); CPPUNIT_ASSERT( (*p.first).first == 'c' ); CPPUNIT_ASSERT( (*p.first).second == 100 );

p = m.insert(pair('c', 100));

CPPUNIT_ASSERT( !p.second ); // already existing pair CPPUNIT_ASSERT( p.first != m.end() ); CPPUNIT_ASSERT( (*p.first).first == 'c' ); CPPUNIT_ASSERT( (*p.first).second == 100 ); }

void MapTest::mmap1() {

typedef multimap> mmap; mmap m;

CPPUNIT_ASSERT(m.count('X')==0);

m.insert(pair('X', 10)); // Standard way. CPPUNIT_ASSERT(m.count('X')==1);

m.insert(pair('X', 20)); // jbuck: standard way CPPUNIT_ASSERT(m.count('X')==2);

m.insert(pair('Y', 32)); // jbuck: standard way mmap::iterator i = m.find('X'); // Find first match. #ifndef _STLP_CONST

# define _STLP_CONST const #endif

pair<_STLP_CONST char, int> p('X', 10); CPPUNIT_ASSERT(*i == p);

CPPUNIT_ASSERT((*i).first == 'X'); CPPUNIT_ASSERT((*i).second == 10); i++;

CPPUNIT_ASSERT((*i).first == 'X'); CPPUNIT_ASSERT((*i).second == 20); i++;

CPPUNIT_ASSERT((*i).first == 'Y'); CPPUNIT_ASSERT((*i).second == 32); i++;

CPPUNIT_ASSERT(i == m.end());

size_t count = m.erase('X');

CPPUNIT_ASSERT(count==2); }

void MapTest::mmap2() {

typedef pair pair_type;

pair_type p1(3, 'c'); pair_type p2(6, 'f'); pair_type p3(1, 'a'); pair_type p4(2, 'b'); pair_type p5(3, 'x'); pair_type p6(6, 'f');

typedef multimap> mmap;

pair_type array [] = { p1, p2, p3, p4, p5, p6 };

mmap m(array + 0, array + 6); mmap::iterator i;

i = m.lower_bound(3);

CPPUNIT_ASSERT((*i).first==3); CPPUNIT_ASSERT((*i).second=='c');

i = m.upper_bound(3);

CPPUNIT_ASSERT((*i).first==6); CPPUNIT_ASSERT((*i).second=='f'); }

void MapTest::iterators() {

typedef map> int_map; int_map imap; {

int_map::iterator ite(imap.begin());

int_map::const_iterator cite(imap.begin());

CPPUNIT_ASSERT( ite == cite ); CPPUNIT_ASSERT( !(ite != cite) ); CPPUNIT_ASSERT( cite == ite ); CPPUNIT_ASSERT( !(cite != ite) ); }

typedef multimap> mmap; typedef mmap::value_type pair_type;

pair_type p1(3, 'c'); pair_type p2(6, 'f'); pair_type p3(1, 'a'); pair_type p4(2, 'b'); pair_type p5(3, 'x'); pair_type p6(6, 'f');

pair_type array [] = { p1, p2, p3, p4, p5, p6 };

mmap m(array+0, array + 6); {

mmap::iterator ite(m.begin());

mmap::const_iterator cite(m.begin());

//test compare between const_iterator and iterator CPPUNIT_ASSERT( ite == cite ); CPPUNIT_ASSERT( !(ite != cite) ); CPPUNIT_ASSERT( cite == ite ); CPPUNIT_ASSERT( !(cite != ite) ); } #if 0 /*

* A check that map and multimap iterators are NOT comparable * the following code should generate a compile time error */ {

int_map::iterator mite(imap.begin());

int_map::const_iterator mcite(imap.begin()); mmap::iterator mmite(m.begin());

mmap::const_iterator mmcite(m.begin()); CPPUNIT_ASSERT( !(mite == mmite) ); CPPUNIT_ASSERT( !(mcite == mmcite) ); CPPUNIT_ASSERT( mite != mmite ); CPPUNIT_ASSERT( mcite != mmcite ); CPPUNIT_ASSERT( !(mite == mmcite) ); CPPUNIT_ASSERT( !(mite == mmcite) ); CPPUNIT_ASSERT( mite != mmcite ); CPPUNIT_ASSERT( mite != mmcite ); }

#endif

mmap::reverse_iterator ri = m.rbegin(); CPPUNIT_ASSERT( ri != m.rend() ); CPPUNIT_ASSERT( ri == m.rbegin() ); CPPUNIT_ASSERT( (*ri).first == 6 );

CPPUNIT_ASSERT( (*ri++).second == 'f' ); CPPUNIT_ASSERT( (*ri).first == 6 ); CPPUNIT_ASSERT( (*ri).second == 'f' );

mmap const& cm = m;

mmap::const_reverse_iterator rci = cm.rbegin(); CPPUNIT_ASSERT( rci != cm.rend() ); CPPUNIT_ASSERT( (*rci).first == 6 );

CPPUNIT_ASSERT( (*rci++).second == 'f' ); CPPUNIT_ASSERT( (*rci).first == 6 ); CPPUNIT_ASSERT( (*rci).second == 'f' ); }

void MapTest::equal_range() {

typedef map> maptype; {

maptype m; m['x'] = 10;

pair ret; ret = m.equal_range('x');

CPPUNIT_ASSERT( ret.first != ret.second ); CPPUNIT_ASSERT( (*(ret.first)).first == 'x' ); CPPUNIT_ASSERT( (*(ret.first)).second == 10 );

CPPUNIT_ASSERT( ++(ret.first) == ret.second ); } { {

maptype m;

maptype::iterator i = m.lower_bound( 'x' ); CPPUNIT_ASSERT( i == m.end() );

i = m.upper_bound( 'x' );

CPPUNIT_ASSERT( i == m.end() );

pair ret; ret = m.equal_range('x');

CPPUNIT_ASSERT( ret.first == ret.second ); CPPUNIT_ASSERT( ret.first == m.end() ); }

{

const maptype m;

pair ret; ret = m.equal_range('x');

CPPUNIT_ASSERT( ret.first == ret.second ); CPPUNIT_ASSERT( ret.first == m.end() ); } } }

void MapTest::allocator_with_state() {

char buf1[1024];

StackAllocator> stack1(buf1, buf1 + sizeof(buf1));

char buf2[1024];

StackAllocator> stack2(buf2, buf2 + sizeof(buf2)); {

typedef map, StackAllocator>> MapInt; less intLess;

MapInt mint1(intLess, stack1); int i;

for (i = 0; i < 5; ++i)

mint1.insert(MapInt::value_type(i, i)); MapInt mint1Cpy(mint1);

MapInt mint2(intLess, stack2); for (; i < 10; ++i)

mint2.insert(MapInt::value_type(i, i)); MapInt mint2Cpy(mint2);

mint1.swap(mint2);

CPPUNIT_ASSERT( mint1.get_allocator().swaped() ); CPPUNIT_ASSERT( mint2.get_allocator().swaped() );

CPPUNIT_ASSERT( mint1 == mint2Cpy ); CPPUNIT_ASSERT( mint2 == mint1Cpy );

CPPUNIT_ASSERT( mint1.get_allocator() == stack2 ); CPPUNIT_ASSERT( mint2.get_allocator() == stack1 ); }

CPPUNIT_ASSERT( stack1.ok() ); CPPUNIT_ASSERT( stack2.ok() ); }

struct Key {

Key() : m_data(0) {}

explicit Key(int data) : m_data(data) {}

int m_data; };

struct KeyCmp {

booloperator () (Key lhs, Key rhs) const { return lhs.m_data < rhs.m_data; }

booloperator () (Key lhs, int rhs) const { return lhs.m_data < rhs; }

booloperator () (int lhs, Key rhs) const { return lhs < rhs.m_data; } };

struct KeyCmpPtr {

booloperator () (Key constvolatile *lhs, Key constvolatile *rhs) const { return (*lhs).m_data < (*rhs).m_data; }

booloperator () (Key constvolatile *lhs, int rhs) const { return (*lhs).m_data < rhs; }

booloperator () (int lhs, Key constvolatile *rhs) const { return lhs < (*rhs).m_data; } };

void MapTest::template_methods() {

#ifdefined (STLPORT) &&defined (_STLP_USE_CONTAINERS_EXTENSION) {

typedef map Container; typedef Container::value_type value; Container cont;

cont.insert(value(Key(1), 1)); cont.insert(value(Key(2), 2)); cont.insert(value(Key(3), 3)); cont.insert(value(Key(4), 4));

CPPUNIT_ASSERT( cont.count(Key(1)) == 1 ); CPPUNIT_ASSERT( cont.count(1) == 1 ); CPPUNIT_ASSERT( cont.count(5) == 0 );

CPPUNIT_ASSERT( cont.find(2) != cont.end() );

CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() ); CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );

CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );

Container const& ccont = cont;

CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );

CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() ); CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );

CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.end(), ccont.end()) ); } {

typedef map Container; typedef Container::value_type value; Container cont;

Key key1(1), key2(2), key3(3), key4(4); cont.insert(value(&key1, 1)); cont.insert(value(&key2, 2)); cont.insert(value(&key3, 3));

cont.insert(value(&key4, 4));

CPPUNIT_ASSERT( cont.count(1) == 1 ); CPPUNIT_ASSERT( cont.count(5) == 0 );

CPPUNIT_ASSERT( cont.find(2) != cont.end() );

CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() ); CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );

CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );

Container const& ccont = cont;

CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );

CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() ); CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );

CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) ); } {

typedef multimap Container; typedef Container::value_type value; Container cont;

cont.insert(value(Key(1), 1)); cont.insert(value(Key(2), 2)); cont.insert(value(Key(3), 3)); cont.insert(value(Key(4), 4));

CPPUNIT_ASSERT( cont.count(Key(1)) == 1 ); CPPUNIT_ASSERT( cont.count(1) == 1 ); CPPUNIT_ASSERT( cont.count(5) == 0 );

CPPUNIT_ASSERT( cont.find(2) != cont.end() );

CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() ); CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );

CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );

Container const& ccont = cont;

CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );

CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() ); CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );

CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.end(), ccont.end()) ); } {

typedef multimap Container; typedef Container::value_type value;

Container cont;

Key key1(1), key2(2), key3(3), key4(4); cont.insert(value(&key1, 1)); cont.insert(value(&key2, 2)); cont.insert(value(&key3, 3)); cont.insert(value(&key4, 4));

CPPUNIT_ASSERT( cont.count(1) == 1 ); CPPUNIT_ASSERT( cont.count(5) == 0 );

CPPUNIT_ASSERT( cont.find(2) != cont.end() );

CPPUNIT_ASSERT( cont.lower_bound(2) != cont.end() ); CPPUNIT_ASSERT( cont.upper_bound(2) != cont.end() );

CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );

Container const& ccont = cont;

CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );

CPPUNIT_ASSERT( ccont.lower_bound(2) != ccont.end() ); CPPUNIT_ASSERT( ccont.upper_bound(2) != ccont.end() );

CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) ); } #endif }

#if !defined (STLPORT) || \\

!defined (_STLP_USE_PTR_SPECIALIZATIONS) || defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) # if !defined (__DMC__)

/* Simple compilation test: Check that nested types like iterator * can be access even if type used to instanciate container is not * yet completely defined. */

class IncompleteClass {

map instances;

typedef map::iterator it; multimap minstances;

typedef multimap::iterator mit; };

# endif #endif

test_hash_map.cpp

/***********************************************************************************

test_hash_map.cpp

* Copyright (c) 1997

* Mark of the Unicorn, Inc. *

* Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Mark of the Unicorn makes no * representations about the suitability of this software for any

* purpose. It is provided \"as is\" without express or implied warranty.

***********************************************************************************/

#include\"Tests.h\"

#ifdefined( EH_HASHED_CONTAINERS_IMPLEMENTED ) #include\"TestClass.h\" #include\"LeakCheck.h\"

# include

#include\"test_construct.h\" #include\"test_assign_op.h\" #include\"test_push_back.h\" #include\"test_insert.h\"

#include\"test_push_front.h\" #include\"ThrowCompare.h\" #include\"test_hash_resize.h\" /*

template struct pair;

template struct __hashtable_node>;

template class hash_map;

template class hash_multimap; */

typedef EH_STD::__hash_multimap__ TestMultiMap;

inline multimap_tag

container_category(const TestMultiMap&) { return multimap_tag(); }

void test_hash_multimap() {

# if !(defined (_MSC_VER) && (_MSC_VER < 1100)) TestMultiMap testMultiMap, testMultiMap2;

const size_t hash_mapSize = random_number(random_base);

while ( testMultiMap.size() < hash_mapSize ) {

TestMultiMap::value_type x; testMultiMap.insert( x );

testMultiMap2.insert( TestMultiMap::value_type() ); }

# ifdefined( EH_HASH_CONTAINERS_SUPPORT_RESIZE ) WeakCheck( testMultiMap, test_hash_resize() ); // TestMultiMap == TestMultiMap: no such operator! - ptr

// StrongCheck( testMultiMap, test_insert_noresize(testMultiMap) ); # endif

WeakCheck( testMultiMap, test_insert_value(testMultiMap) );

size_t insCnt = random_number(random_base);

TestMultiMap::value_type *insFirst = new TestMultiMap::value_type[1+insCnt];

WeakCheck( testMultiMap, insert_range_tester(testMultiMap, insFirst, insFirst+insCnt) ); ConstCheck( 0, test_construct_pointer_range(insFirst, insFirst+insCnt) ); delete[] insFirst;

WeakCheck( testMultiMap, insert_range_tester(testMultiMap, testMultiMap2.begin(), testMultiMap2.end() ) );

ConstCheck( 0, test_default_construct() );

# if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION ConstCheck( 0, test_construct_iter_range_n( testMultiMap2 ) ); # endif

ConstCheck( testMultiMap, test_copy_construct() );

WeakCheck( testMultiMap, test_assign_op( testMultiMap2 ) ); # endif }

typedef EH_STD::__hash_map__ TestMap;

inline map_tag

container_category(const TestMap&) {

return map_tag(); }

void test_hash_map() {

# if !(defined (_MSC_VER) && (_MSC_VER < 1100)) TestMap testMap, testMap2;

const size_t hash_mapSize = random_number(random_base);

while ( testMap.size() < hash_mapSize ) { TestMap::value_type x; testMap.insert( x );

testMap2.insert( TestMap::value_type() ); }

#ifdefined( EH_HASH_CONTAINERS_SUPPORT_RESIZE ) WeakCheck( testMap, test_hash_resize() ); // TestMultiMap == TestMultiMap: no such operator! - ptr

// StrongCheck( testMap, test_insert_noresize(testMap) ); #endif

WeakCheck( testMap, test_insert_value(testMap) );

size_t insCnt = random_number(random_base);

TestMap::value_type *insFirst = new TestMap::value_type[1+insCnt];

WeakCheck( testMap, insert_range_tester(testMap, insFirst, insFirst+insCnt) );

ConstCheck( 0, test_construct_pointer_range(insFirst, insFirst+insCnt) ); delete[] insFirst;

WeakCheck( testMap, insert_range_tester(testMap, testMap2.begin(), testMap2.end() ) );

ConstCheck( 0, test_default_construct() );

# if EH_HASH_CONTAINERS_SUPPORT_ITERATOR_CONSTRUCTION ConstCheck( 0, test_construct_iter_range_n( testMap2 ) ); # endif

ConstCheck( testMap, test_copy_construct() );

WeakCheck( testMap, test_assign_op( testMap2 ) ); # endif }

#endif// EH_HASHED_CONTAINERS_IMPLEMENTED

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- azee.cn 版权所有

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务