关联容器模板型别

template <class Key, class Value, class KeyOfValue, class Compare,
          class Alloc = alloc>
class rb_tree {}
型别说明:Key 键值类型
		  Value  元素型别
		  KeyOfValue 仿函数,由元素型别得出键值型别
		  Comapre 仿函数,比较键值
		  Alloc 空间配置器

		  
		  
template <class Key, class T, class Compare = less<Key>, class Alloc = alloc>
class map {
 typedef rb_tree<key_type, value_type, 
                  select1st<value_type>, key_compare, Alloc> rep_type;
  rep_type t; 
}
型别说明:Key 键值型别
		  T 实值型别
		  Comapre 仿函数,键值比较
		  Alloc 空间配置器
		  

template <class Key, class Compare = less<Key>, class Alloc = alloc>
class set {
 typedef rb_tree<key_type, value_type, 
                  identity<value_type>, key_compare, Alloc> rep_type;
  rep_type t; 
}
型别说明:Key 键值型别(也是实值型别)
		  Comapre 仿函数,键值比较
		  Alloc 空间配置器


///以上以rb-tree为底层机制,一下以hash-table为底层机制


		  
		  
template <class Value, class Key, class HashFcn,
          class ExtractKey, class EqualKey,
          class Alloc>
class hashtable {}
型别说明:Value 元素型别
		  Key 键值型别
		  HashFcn 仿函数,由键值确定插入位置
		  ExtractKey 仿函数,由元素得出键值
		  EqualKey 仿函数,键值是否相等
		  Alloc 空间配置器

		  
template <class Key, class T, class HashFcn, class EqualKey, 
          class Alloc = alloc>
class hash_map
{
private:
  typedef hashtable<pair<const Key, T>, Key, HashFcn,
                    select1st<pair<const Key, T> >, EqualKey, Alloc> ht;
  ht rep;
}
型别说明:Key 键值型别
		  T 实值型别
		  HashFcn 仿函数,由键值确定插入位置
		  EqualKey 仿函数,键值是否相等
		  Alloc 空间配置器
		  
		  

template <class Value, class HashFcn = hash<Value>,
          class EqualKey = equal_to<Value>,
          class Alloc = alloc>
class hash_set
{
private:
  typedef hashtable<Value, Value, HashFcn, identity<Value>, 
                    EqualKey, Alloc> ht;
  ht rep;
}
型别说明:Value 键值型别(也是实值型别)
		  HashFcn 仿函数,由键值确定插入位置
		  EqualKey 仿函数,键值是否相等
		  Alloc 空间配置器

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值