【正文】
time proportional to the logarithm of the number of elements in the container for sorting techniques.(logN) ? The value of an element in a hash_map, but not its associated key value, may be changed directly. Instead, key values associated with old elements must be deleted and new key values associated with new elements inserted. Use hash_map? ? Hashed associative containers are optimized for the operations of lookup, insertion and removal. ? Hash_multimap ? hash_set ? hash_multiset 定義、插入、遍歷、刪除、查詢 include hash_map include iostream int main( ) { using namespace std。例如 map 可以很好地支持電話目錄,鍵是人名,值是相關(guān)聯(lián)的電話號(hào)碼。它通過兩級(jí)數(shù)組結(jié)構(gòu)來實(shí)現(xiàn)。j = ( 1 )。 *ptr = 44。v1[0], amp。 還有 ==, +等操作符函數(shù)),就可以統(tǒng)一方式遍歷容器的各元素 Vector的迭代器 改進(jìn) Find()函數(shù) 容器的共同操作 ? Vector, list, map, set, queue, deque, stack ? 包括 string類 容器的共同操作 序列式容器 邏輯上排列有序的容器: ? Vector ? List ? Deque ? Queue ? Stack vector ? template class Type, class Allocator = allocatorType class vector Header vector vector ? pointer指針 vectorint::pointer ptr = amp。 ( 10 )。 ? 但是在任意位置而不是在 vector 末尾插人元素則效率很低,因?yàn)樗枰汛迦朐赜疫叺拿總€(gè)元素都拷貝一遍。從而允許向前和向后兩個(gè)方向進(jìn)行遍歷。 multimap/多映射和 multiset/ 多集合支持同一個(gè)鍵的多次出現(xiàn)。 hash_map int, int hm1, hm2。 hm1_pIter != ( )。 // The function removes an element at a given position Iter1 = ++( )