分享
 
 
 

C++ young 程序库——y_hash_set.hpp 和 y_hash_map.hpp

王朝c/c++·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

文件位置:young/y_hash_set.hpp

/*

The young Library

Copyright (c) 2005 by 杨桓

Permission to use, copy, modify, distribute and sell this software 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.

The author make no representations about the suitability of this software

for any purpose. It is provided "as is" without express or implied warranty.

*/

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

#ifndef __MACRO_CPLUSPLUS_YOUNG_LIBRARY_HASH_SET_HEADER_FILE__

#define __MACRO_CPLUSPLUS_YOUNG_LIBRARY_HASH_SET_HEADER_FILE__

//-----------------------------------------------------------------------------

#include "y_pair.hpp"

#include "y_functional.hpp"

#include "hash/y_hash_function.hpp"

#include "hash/y_hash_table.hpp"

//-----------------------------------------------------------------------------

__MACRO_CPLUSPLUS_YOUNG_LIBRARY_BEGIN_NAMESPACE__

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

template< typename Key, typename HashFun = hash<Key>,

typename EqualKey = equal_to<Key>,

typename Allocator = allocator<Key> >

class hash_set

{

private:

typedef hash_table_node<Key> node;

typedef typename Allocator::rebind<node>::other node_alloc;

typedef hash_table<Key, Key, HashFun, identity<Key>, EqualKey,

node_alloc> hash_table;

// typedef hash_table<Key, Key, HashFun, identity<Key>, EqualKey>

// hash_table;

typedef typename hash_table::iterator ht_iterator;

hash_table ht;

public:

typedef hash_set<Key, HashFun, EqualKey, Allocator> self;

typedef typename hash_table::key_type key_type;

typedef typename hash_table::value_type value_type;

typedef typename hash_table::hasher hasher;

typedef typename hash_table::key_equal key_equal;

typedef typename hash_table::size_type size_type;

typedef typename hash_table::difference_type difference_type;

typedef typename hash_table::const_reference reference;

typedef typename hash_table::const_reference const_reference;

typedef typename hash_table::const_pointer pointer;

typedef typename hash_table::const_pointer const_pointer;

typedef typename hash_table::const_iterator iterator;

typedef typename hash_table::const_iterator const_iterator;

hash_set() : ht(0) {}

explicit hash_set( size_type n, const hasher& hf = hasher(),

const key_equal& eq = key_equal() ) : ht(n, hf, eq) {}

template< typename InputIterator >

hash_set( InputIterator first, InputIterator last,

size_type n = 0, const hasher& hf = hasher(),

const key_equal& eq = key_equal() ) : ht(n, hf, eq)

{

ht.insert_unique( first, last );

}

hasher hash_fun() const { return ht.hash_fun(); }

key_equal key_eq() const { return ht.key_eq(); }

double get_hash_factor() const { return ht.get_hash_factor(); }

void set_hash_factor( double factor ) { ht.set_hash_factor(factor); }

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

size_type max_size() const { return ht.max_size(); }

bool empty() const { return ht.empty(); }

void swap( self& rhs ) { ht.swap( rhs.ht ); }

void clear() { ht.clear(); }

void resize( size_type n ) { ht.resize( n ); }

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

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

size_type elems_in_bucket( size_type n ) const

{ return ht.elements_in_bucket( n ); }

size_type count( const key_type& k ) const

{ return ht.count( k ); }

iterator begin() const { return ht.begin(); }

iterator end() const { return ht.end(); }

iterator find( const key_type& k ) const

{ return ht.find( k ); }

pair<iterator, iterator> equal_range( const key_type& k ) const

{ return ht.equal_range( k ); }

size_type erase( const key_type& k ) { return ht.erase( k ); }

void erase( iterator pos ) { ht.erase( pos ); }

void erase( iterator first, iterator last ) { ht.erase( first, last ); }

iterator modify_key( const key_type& k, const key_type& new_key )

{ return ht.modify_key_unique( k, new_key ); }

bool modify_key( iterator position, const key_type& new_key )

{ return ht.modify_key_unique( position, new_key ); }

pair<iterator, bool> insert( const value_type& v )

{

pair<ht_iterator, bool> pItr = ht.insert_unique( v );

return pair<iterator, bool>( pItr.first, pItr.second );

}

template< typename InputIterator >

void insert( InputIterator first, InputIterator last )

{

ht.insert_unique( first, last );

}

};

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline void swap( hash_set<Key, HashFun, EqualKey, Allocator>& lhs,

hash_set<Key, HashFun, EqualKey, Allocator>& rhs )

{

lhs.swap( rhs );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator==( const hash_set<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_set<Key, HashFun, EqualKey, Allocator>& rhs )

{

if( lhs.size() != rhs.size() || lhs.bucket_count() != rhs.bucket_count() )

return false;

return equal( lhs.begin(), lhs.end(), rhs.begin() );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator!=( const hash_set<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_set<Key, HashFun, EqualKey, Allocator>& rhs )

{

return !( lhs == rhs );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator<( const hash_set<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_set<Key, HashFun, EqualKey, Allocator>& rhs )

{

if( lhs.size() > rhs.size() || lhs.bucket_count() > rhs.bucket_count() )

return false;

return lexicographical_compare( lhs.begin(), lhs.end(),

rhs.begin(), rhs.end() );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator>( const hash_set<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_set<Key, HashFun, EqualKey, Allocator>& rhs )

{

return ( rhs < lhs );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator<=( const hash_set<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_set<Key, HashFun, EqualKey, Allocator>& rhs )

{

return !( rhs < lhs );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator>=( const hash_set<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_set<Key, HashFun, EqualKey, Allocator>& rhs )

{

return !( lhs < rhs );

}

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

template< typename Key, typename HashFun = hash<Key>,

typename EqualKey = equal_to<Key>,

typename Allocator = allocator<Key> >

class hash_multiset

{

private:

typedef hash_table_node<Key> node;

typedef typename Allocator::rebind<node>::other node_alloc;

typedef hash_table<Key, Key, HashFun, identity<Key>, EqualKey,

node_alloc> hash_table;

// typedef hash_table<Key, Key, HashFun, identity<Key>, EqualKey>

// hash_table;

typedef typename hash_table::iterator ht_iterator;

hash_table ht;

public:

typedef hash_multiset<Key, HashFun, EqualKey, Allocator> self;

typedef typename hash_table::key_type key_type;

typedef typename hash_table::value_type value_type;

typedef typename hash_table::hasher hasher;

typedef typename hash_table::key_equal key_equal;

typedef typename hash_table::size_type size_type;

typedef typename hash_table::difference_type difference_type;

typedef typename hash_table::const_reference reference;

typedef typename hash_table::const_reference const_reference;

typedef typename hash_table::const_pointer pointer;

typedef typename hash_table::const_pointer const_pointer;

typedef typename hash_table::const_iterator iterator;

typedef typename hash_table::const_iterator const_iterator;

hash_multiset() : ht(0) {}

explicit hash_multiset( size_type n, const hasher& hf = hasher(),

const key_equal& eq = key_equal() ) : ht(n, hf, eq) {}

template< typename InputIterator >

hash_multiset( InputIterator first, InputIterator last,

size_type n = 0, const hasher& hf = hasher(),

const key_equal& eq = key_equal() ) : ht(n, hf, eq)

{

ht.insert_equal( first, last );

}

hasher hash_fun() const { return ht.hash_fun(); }

key_equal key_eq() const { return ht.key_eq(); }

double get_hash_factor() const { return ht.get_hash_factor(); }

void set_hash_factor( double factor ) { ht.set_hash_factor(factor); }

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

size_type max_size() const { return ht.max_size(); }

bool empty() const { return ht.empty(); }

void swap( self& rhs ) { ht.swap( rhs.ht ); }

void clear() { ht.clear(); }

void resize( size_type n ) { ht.resize( n ); }

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

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

size_type elems_in_bucket( size_type n ) const

{ return ht.elements_in_bucket( n ); }

size_type count( const key_type& k ) const

{ return ht.count( k ); }

iterator begin() const { return ht.begin(); }

iterator end() const { return ht.end(); }

iterator find( const key_type& k ) const

{ return ht.find( k ); }

pair<iterator, iterator> equal_range( const key_type& k ) const

{ return ht.equal_range( k ); }

size_type erase( const key_type& k ) { return ht.erase( k ); }

void erase( iterator pos ) { ht.erase( pos ); }

void erase( iterator first, iterator last ) { ht.erase( first, last ); }

void modify_key( const key_type& k, const key_type& new_key )

{ ht.modify_key_equal( k, new_key ); }

void modify_key( iterator position, const key_type& new_key )

{ ht.modify_key_equal( position, new_key ); }

pair<iterator, bool> insert( const value_type& v )

{

pair<ht_iterator, bool> pItr = ht.insert_equal( v );

return pair<iterator, bool>( pItr.first, pItr.second );

}

template< typename InputIterator >

void insert( InputIterator first, InputIterator last )

{

ht.insert_equal( first, last );

}

};

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline void swap( hash_multiset<Key, HashFun, EqualKey, Allocator>& lhs,

hash_multiset<Key, HashFun, EqualKey, Allocator>& rhs )

{

lhs.swap( rhs );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator==( const hash_multiset<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_multiset<Key, HashFun, EqualKey, Allocator>& rhs )

{

if( lhs.size() != rhs.size() || lhs.bucket_count() != rhs.bucket_count() )

return false;

return equal( lhs.begin(), lhs.end(), rhs.begin() );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator!=( const hash_multiset<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_multiset<Key, HashFun, EqualKey, Allocator>& rhs )

{

return !( lhs == rhs );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator<( const hash_multiset<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_multiset<Key, HashFun, EqualKey, Allocator>& rhs )

{

if( lhs.size() > rhs.size() || lhs.bucket_count() > rhs.bucket_count() )

return false;

return lexicographical_compare( lhs.begin(), lhs.end(),

rhs.begin(), rhs.end() );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator>( const hash_multiset<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_multiset<Key, HashFun, EqualKey, Allocator>& rhs )

{

return ( rhs < lhs );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator<=( const hash_multiset<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_multiset<Key, HashFun, EqualKey, Allocator>& rhs )

{

return !( rhs < lhs );

}

template< typename Key, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator>=( const hash_multiset<Key, HashFun, EqualKey, Allocator>& lhs,

const hash_multiset<Key, HashFun, EqualKey, Allocator>& rhs )

{

return !( lhs < rhs );

}

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

__MACRO_CPLUSPLUS_YOUNG_LIBRARY_END_NAMESPACE__

#endif

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

文件位置:young/y_hash_map.hpp

/*

The young Library

Copyright (c) 2005 by 杨桓

Permission to use, copy, modify, distribute and sell this software 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.

The author make no representations about the suitability of this software

for any purpose. It is provided "as is" without express or implied warranty.

*/

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

#ifndef __MACRO_CPLUSPLUS_YOUNG_LIBRARY_HASH_MAP_HEADER_FILE__

#define __MACRO_CPLUSPLUS_YOUNG_LIBRARY_HASH_MAP_HEADER_FILE__

//-----------------------------------------------------------------------------

#include "y_pair.hpp"

#include "y_functional.hpp"

#include "hash/y_hash_function.hpp"

#include "hash/y_hash_table.hpp"

//-----------------------------------------------------------------------------

__MACRO_CPLUSPLUS_YOUNG_LIBRARY_BEGIN_NAMESPACE__

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

template< typename Key, typename Value, typename HashFun = hash<Key>,

typename EqualKey = equal_to<Key>,

typename Allocator = allocator<Value> >

class hash_map

{

private:

typedef pair<const Key, Value> value_t;

typedef hash_table_node<value_t> node;

typedef typename Allocator::rebind<node>::other node_alloc;

typedef hash_table<Key, value_t, HashFun, select1st<value_t>,

EqualKey, node_alloc> hash_table;

// typedef hash_table<Key, value_t, HashFun, select1st<value_t>,

// EqualKey> hash_table;

hash_table ht;

public:

typedef hash_map<Key, Value, HashFun, EqualKey, Allocator> self;

typedef Value mapped_type;

typedef typename hash_table::key_type key_type;

typedef typename hash_table::value_type value_type;

typedef typename hash_table::hasher hasher;

typedef typename hash_table::key_equal key_equal;

typedef typename hash_table::size_type size_type;

typedef typename hash_table::difference_type difference_type;

typedef typename hash_table::reference reference;

typedef typename hash_table::const_reference const_reference;

typedef typename hash_table::pointer pointer;

typedef typename hash_table::const_pointer const_pointer;

typedef typename hash_table::iterator iterator;

typedef typename hash_table::const_iterator const_iterator;

struct value_compare : public binary_function<value_type, value_type, bool>

{

bool operator()( const value_type& lhs, const value_type& rhs ) const

{

return ( lhs.first < rhs.first );

}

};

hash_map() : ht(0) {}

explicit hash_map( size_type n, const hasher& hf = hasher(),

const key_equal& eq = key_equal() ) : ht(n, hf, eq) {}

template< typename InputIterator >

hash_map( InputIterator first, InputIterator last,

size_type n = 0, const hasher& hf = hasher(),

const key_equal& eq = key_equal() ) : ht(n, hf, eq)

{

ht.insert_unique( first, last );

}

hasher hash_fun() const { return ht.hash_fun(); }

key_equal key_eq() const { return ht.key_eq(); }

double get_hash_factor() const { return ht.get_hash_factor(); }

void set_hash_factor( double factor ) { ht.set_hash_factor(factor); }

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

size_type max_size() const { return ht.max_size(); }

bool empty() const { return ht.empty(); }

void swap( self& rhs ) { ht.swap( rhs.ht ); }

void clear() { ht.clear(); }

void resize( size_type n ) { ht.resize( n ); }

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

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

size_type elems_in_bucket( size_type n ) const

{ return ht.elements_in_bucket( n ); }

size_type count( const key_type& k ) const

{ return ht.count( k ); }

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

iterator end() { return ht.end(); }

const_iterator begin() const { return ht.begin(); }

const_iterator end() const { return ht.end(); }

iterator find( const key_type& k )

{ return ht.find( k ); }

const_iterator find( const key_type& k ) const

{ return ht.find( k ); }

pair<iterator, iterator> equal_range( const key_type& k )

{ return ht.equal_range( k ); }

pair<const_iterator, const_iterator> equal_range( const key_type& k ) const

{ return ht.equal_range( k ); }

size_type erase( const key_type& k ) { return ht.erase( k ); }

void erase( iterator pos ) { ht.erase( pos ); }

void erase( iterator first, iterator last ) { ht.erase( first, last ); }

iterator modify_key( const key_type& k, const key_type& new_key )

{ return ht.modify_key_unique( k, new_key ); }

bool modify_key( iterator position, const key_type& new_key )

{ return ht.modify_key_unique( position, new_key ); }

mapped_type& operator[]( const key_type& k )

{

value_type v( k, mapped_type() );

iterator itr = insert( v ).first;

return itr->second;

}

pair<iterator, bool> insert( const key_type& k, const mapped_type& d )

{ return ht.insert_unique( value_type(k, d) ); }

pair<iterator, bool> insert( const value_type& v )

{ return ht.insert_unique( v ); }

template< typename InputIterator >

void insert( InputIterator first, InputIterator last )

{ ht.insert_unique( first, last ); }

};

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline void swap( hash_map<Key, Value, HashFun, EqualKey, Allocator>& lhs,

hash_map<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

lhs.swap( rhs );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator==( const hash_map<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_map<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

if( lhs.size() != rhs.size() || lhs.bucket_count() != rhs.bucket_count() )

return false;

return equal( lhs.begin(), lhs.end(), rhs.begin() );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator!=( const hash_map<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_map<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

return !( lhs == rhs );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator<( const hash_map<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_map<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

typedef typename hash_map<Key, Value, HashFun, EqualKey, Allocator>::

value_compare v_comp;

if( lhs.size() > rhs.size() || lhs.bucket_count() > rhs.bucket_count() )

return false;

return lexicographical_compare( lhs.begin(), lhs.end(),

rhs.begin(), rhs.end(), v_comp() );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator>( const hash_map<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_map<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

return ( rhs < lhs );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator<=( const hash_map<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_map<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

return !( rhs < lhs );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator>=( const hash_map<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_map<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

return !( lhs < rhs );

}

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

template< typename Key, typename Value, typename HashFun = hash<Key>,

typename EqualKey = equal_to<Key>,

typename Allocator = allocator<Value> >

class hash_multimap

{

private:

typedef pair<const Key, Value> value_t;

typedef hash_table_node<value_t> node;

typedef typename Allocator::rebind<node>::other node_alloc;

typedef hash_table<Key, value_t, HashFun, select1st<value_t>,

EqualKey, node_alloc> hash_table;

// typedef hash_table<Key, value_t, HashFun, select1st<value_t>,

// EqualKey> hash_table;

hash_table ht;

public:

typedef hash_multimap<Key, Value, HashFun, EqualKey, Allocator> self;

typedef Value mapped_type;

typedef typename hash_table::key_type key_type;

typedef typename hash_table::value_type value_type;

typedef typename hash_table::hasher hasher;

typedef typename hash_table::key_equal key_equal;

typedef typename hash_table::size_type size_type;

typedef typename hash_table::difference_type difference_type;

typedef typename hash_table::reference reference;

typedef typename hash_table::const_reference const_reference;

typedef typename hash_table::pointer pointer;

typedef typename hash_table::const_pointer const_pointer;

typedef typename hash_table::iterator iterator;

typedef typename hash_table::const_iterator const_iterator;

struct value_compare : public binary_function<value_type, value_type, bool>

{

bool operator()( const value_type& lhs, const value_type& rhs ) const

{

return ( lhs.first < rhs.first );

}

};

hash_multimap() : ht(0) {}

explicit hash_multimap( size_type n, const hasher& hf = hasher(),

const key_equal& eq = key_equal() )

: ht(n, hf, eq) {}

template< typename InputIterator >

hash_multimap( InputIterator first, InputIterator last,

size_type n = 0, const hasher& hf = hasher(),

const key_equal& eq = key_equal() ) : ht(n, hf, eq)

{

ht.insert_equal( first, last );

}

hasher hash_fun() const { return ht.hash_fun(); }

key_equal key_eq() const { return ht.key_eq(); }

double get_hash_factor() const { return ht.get_hash_factor(); }

void set_hash_factor( double factor ) { ht.set_hash_factor(factor); }

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

size_type max_size() const { return ht.max_size(); }

bool empty() const { return ht.empty(); }

void swap( self& rhs ) { ht.swap( rhs.ht ); }

void clear() { ht.clear(); }

void resize( size_type n ) { ht.resize( n ); }

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

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

size_type elems_in_bucket( size_type n ) const

{ return ht.elements_in_bucket( n ); }

size_type count( const key_type& k ) const

{ return ht.count( k ); }

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

iterator end() { return ht.end(); }

const_iterator begin() const { return ht.begin(); }

const_iterator end() const { return ht.end(); }

iterator find( const key_type& k )

{ return ht.find( k ); }

const_iterator find( const key_type& k ) const

{ return ht.find( k ); }

pair<iterator, iterator> equal_range( const key_type& k )

{ return ht.equal_range( k ); }

pair<const_iterator, const_iterator> equal_range( const key_type& k ) const

{ return ht.equal_range( k ); }

size_type erase( const key_type& k ) { return ht.erase( k ); }

void erase( iterator pos ) { ht.erase( pos ); }

void erase( iterator first, iterator last ) { ht.erase( first, last ); }

void modify_key( const key_type& k, const key_type& new_key )

{ ht.modify_key_equal( k, new_key ); }

void modify_key( iterator position, const key_type& new_key )

{ ht.modify_key_equal( position, new_key ); }

pair<iterator, bool> insert( const key_type& k, const mapped_type& d )

{ return ht.insert_equal( value_type(k, d) ); }

pair<iterator, bool> insert( const value_type& v )

{ return ht.insert_equal( v ); }

template< typename InputIterator >

void insert( InputIterator first, InputIterator last )

{ ht.insert_equal( first, last ); }

};

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline void swap( hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& lhs,

hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

lhs.swap( rhs );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator==( const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

if( lhs.size() != rhs.size() || lhs.bucket_count() != rhs.bucket_count() )

return false;

return equal( lhs.begin(), lhs.end(), rhs.begin() );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator!=( const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

return !( lhs == rhs );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator<( const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

typedef typename hash_multimap<Key, Value, HashFun, EqualKey, Allocator>::

value_compare v_comp;

if( lhs.size() > rhs.size() || lhs.bucket_count() > rhs.bucket_count() )

return false;

return lexicographical_compare( lhs.begin(), lhs.end(),

rhs.begin(), rhs.end(), v_comp() );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator>( const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

return ( rhs < lhs );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator<=( const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

return !( rhs < lhs );

}

template< typename Key, typename Value, typename HashFun, typename EqualKey,

typename Allocator >

inline

bool operator>=( const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& lhs,

const hash_multimap<Key, Value, HashFun, EqualKey, Allocator>& rhs )

{

return !( lhs < rhs );

}

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

__MACRO_CPLUSPLUS_YOUNG_LIBRARY_END_NAMESPACE__

#endif

//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有