
Unordered Containers也是一种关联式容器。其中元素是分散,没有定性的排列(不是图中那样松散)。其中元素可能在某一次操作后改变原来的位置。

哈希表的链地址法,更能表现其内部实现结构。其中哈希表中表长可以改变,其实现用分配器实现,
为了防止链表过程,效率减低,设置一个值,当链表长度过长时(大于等于表长),打散哈希表,重新设置表长,分配位置。
二:性能测试
![]()
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <cstring>
#if _MSC_VER
#define snprintf _snprintf
#endif
using namespace std;
long get_a_target_long()
{
/******变量声明********/
long target = 0;
/**********************/
cout << "targer (0~" << RAND_MAX << "):";
cin >> target;
return target;
}
string get_a_target_string()
{
/******变量声明********/
long target = 0;
char buf[10];
/**********************/
cout << "targer (0~" << RAND_MAX << "):";
cin >> target;
snprintf(buf, 10, "%d", target);
return string(buf);
}
//与后面的比较函数中回调参数对应
int compareLongs(const void* l1, const void* l2)
{
return (*(long*)l1 - *(long*)l2);
}
int compareStrings(const void* s1, const void* s2)
{
if (*(string*)s1 > *(string*)s2)
return 1;
if (*(string*)s1 < *(string*)s2)
return -1;
return 0;
}
公共函数