[#stats]
== 统计信息

:idprefix: stats_

开放寻址和并发容器可配置为持续统计受所提供哈希函数质量影响的某些内部操作。

=== 概要

[listing,subs="+macros,+quotes"]
-----
struct xref:#stats_stats_summary_type[__stats-summary-type__]
{
  double average;
  double variance;
  double deviation;
};

struct xref:#stats_insertion_stats_type[__insertion-stats-type__]
{
  std::size_t        count;
  xref:#stats_stats_summary_type[__stats-summary-type__] probe_length;
};

struct xref:stats_lookup_stats_type[__lookup-stats-type__]
{
  std::size_t        count;
  xref:#stats_stats_summary_type[__stats-summary-type__] probe_length;
  xref:#stats_stats_summary_type[__stats-summary-type__] num_comparisons;
};

struct xref:reference/stats.adoc#stats_stats_type[__stats-type__]
{
  xref:#stats_insertion_stats_type[__insertion-stats-type__] insertion;
  xref:stats_lookup_stats_type[__lookup-stats-type__]    successful_lookup,
                       unsuccessful_lookup;
};
-----

==== _统计摘要类型_

提供数值序列的平均值、方差和标准差。

==== _插入统计类型_

提供容器执行的插入操作次数及相关__探查长度__（每次操作访问的 xref:structures.adoc#structures_open_addressing_containers[桶组] 数量）的统计信息。

==== _查找统计类型_

对于成功（找到元素）或失败（未找到）查找操作，提供容器执行的操作次数及相关__探查长度__（访问的 xref:structures.adoc#structures_open_addressing_containers[桶组] 数量）和每次操作的元素比较次数的统计信息。

==== _stats-type_

提供容器执行的插入操作、成功及失败查找操作的统计信息。若提供的哈希函数质量良好，则：

* 平均探查长度应接近1.0。
* 对于成功查找，平均元素比较次数应接近 1.0。
* 对于失败查找，平均元素比较次数应接近 0.0。

这些统计信息可用于判断给定的哈希函数是否可被标记为 link:../../../../../container_hash/doc/html/hash.html#ref_hash_is_avalanchinghash[_雪崩效应_] 。

---
