prg_string_hash_table_create()

Abstract

Creates a new hash table.

Syntax

prg_string_hash_table_create (table_size, max_chars)
Argument Type Description
table_size int The number of cells the hash table should contain.
max_chars int The maximum number of characters in the key string that should be used when computing the hash value.

Return Type

PrgT_String_Hash_Table *

Pointer to the new hash table.

prg_string_hash_funcs.h

Details

This function creates a new hash table owned by the caller. The number of cells in the table will not change as new (key,value) pairs are added.

WARNING: This function is MT unsafe, as described in “Multi-Threading Safety“ on page 11. Access to shared hash tables must be externally serialized.

The value of table_size relative to the number of (key,value) pairs inserted into the table will help determine the average “lookup speed” of keys. Generally, table_size should be on the order of the maximum number of items expected in the hash table.

  • A smaller size means more collisions and thus longer search times for a specified key.
  • A larger size means fewer collisions and reduced search time, but increased memory requirements.

For this data structure, only strings can be used as keys. Select a value for max_chars that will most likely capture the unique characters of the anticipated strings. This value can affect the efficiency of hashing:

  • A larger value means the hash function computation takes longer.
  • A smaller value can mean many strings will hash to the same cell, resulting in a large number of items per cell.

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com