C++ STL----associative containers

原创
2010/06/08 11:14
阅读数 168

Set:

Sets are typically implemented as binary search trees.

Therefore, the main characteristics of set as an associative container are:

  • Unique element values: no two elements in the set can compare equal to each other. For a similar associative container allowing for multiple equivalent elements, see multiset.
  • The element value is the key itself. For a similar associative container where elements are accessed using a key, but map to a value different than this key, see map.
  • Elements follow a strict weak ordering at all times. Unordered associative arrays, like unordered_set, are available in implementations following TR1.

Map:

As associative containers, they are especially designed to be efficient accessing its elements by their key (unlike sequence containers, which are more efficient accessing elements by their relative or absolute position). 

Therefore, the main characteristics of a map as an associative container are:

  • Unique key values: no two elements in the map have keys that compare equal to each other. For a similar associative container allowing for multiple elements with equivalent keys, see multimap.
  • Each element is composed of a key and a mapped value. For a simpler associative container where the element value itself is its key, see set.
  • Elements follow a strict weak ordering at all times. Unordered associative arrays, like unordered_map, are available in implementations following TR1.

Bitset:

A bitset is a special container class that is designed to store bits (elements with only two possible values: 0 or 1, true or false, ...).

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部