Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
3.1 KiB

  1. #if _MSC_VER > 1000
  2. #pragma once
  3. #endif // _MSC_VER > 1000
  4. template< class Key, class T, const size_t Buckets, class HashFun= hash<Key>,
  5. class EqualKey= equal_to<Key>,
  6. class Allocator= allocator<pair<Key const, T> > >
  7. class static_hash_map:
  8. public static_hash_table<pair<const Key, T>, Buckets, Key, HashFun,
  9. select1st<pair<Key const, T> >, EqualKey, Allocator>
  10. {
  11. public: // Types
  12. typedef static_hash_map< Key, T, Buckets, HashFun, EqualKey, Allocator>
  13. map_type;
  14. typedef static_hash_table<pair<Key const, T>, Buckets, Key, HashFun,
  15. select1st<pair<Key const, T> >, EqualKey, Allocator> table_type;
  16. typedef typename table_type::key_type key_type;
  17. typedef typename Allocator::rebind< T>::other mapped_type;
  18. typedef typename table_type::value_type value_type;
  19. typedef typename table_type::hasher hasher;
  20. typedef typename table_type::key_equal key_equal;
  21. typedef typename table_type::pointer pointer;
  22. typedef typename table_type::const_pointer const_pointer;
  23. typedef typename table_type::reference reference;
  24. typedef typename table_type::const_reference const_reference;
  25. typedef typename table_type::size_type size_type;
  26. typedef typename table_type::difference_type difference_type;
  27. typedef typename table_type::iterator iterator;
  28. typedef typename table_type::const_iterator const_iterator;
  29. typedef typename table_type::reverse_iterator reverse_iterator;
  30. typedef typename table_type::const_reverse_iterator const_reverse_iterator;
  31. typedef typename table_type::allocator_type allocator_type;
  32. public: // Functions.
  33. using table_type::begin;
  34. using table_type::end;
  35. using table_type::rbegin;
  36. using table_type::rend;
  37. using table_type::size;
  38. using table_type::max_size;
  39. using table_type::empty;
  40. using table_type::bucket_count;
  41. using table_type::resize;
  42. using table_type::hash_funct;
  43. using table_type::key_eq;
  44. explicit static_hash_map( const HashFun& h= HashFun(),
  45. const EqualKey& k= EqualKey(),
  46. const Allocator& A= Allocator())
  47. :table_type( h, k, select1st< value_type>(), A)
  48. { }
  49. template< class InputIterator>
  50. static_hash_map( InputIterator f, InputIterator l,
  51. const HashFun& h= HashFun(), const EqualKey& k= EqualKey(),
  52. const Allocator& A= Allocator())
  53. :table_type( h, k, select1st< value_type>(), A)
  54. { insert( f, l); }
  55. static_hash_map( const map_type& Other): table_type( Other)
  56. { }
  57. ~static_hash_map()
  58. { }
  59. using table_type::operator=;
  60. using table_type::get_allocator;
  61. using table_type::swap;
  62. pair< iterator, bool> insert( const value_type& x)
  63. { return table_type::insert_unique( x); }
  64. template< class InputIterator>
  65. void insert( InputIterator f, InputIterator l)
  66. { return table_type::insert_unique( f, l); }
  67. using table_type::erase;
  68. using table_type::find;
  69. using table_type::count;
  70. using table_type::equal_range;
  71. mapped_type& operator[]( const key_type& k)
  72. {
  73. iterator itEntry( insert( value_type( k, mapped_type())));
  74. return itEntry->second;
  75. }
  76. };
  77. // TODO: Global operators.