prg_mapping_create()

Abstract

Creates a one-to-one mapping between keys and values.

Syntax

prg_mapping_create (key_of_value_proc, lessthan_proc, destroy_proc)
Argument Type Description
key_of_value_proc PrgT_Mapping_Key_Of_Value_Proc Function used by the prg_mapping package to compute the key associated with a given value
lessthan_proc PrgT_Mapping_Key_Lessthan_Proc Function used by the prg_mapping package to compare two keys to find out if one is less than the other or not.
This can be PRGC_NIL, in which case the `<` operator is used on the key values.
destroy_proc PrgT_Mapping_Value_Destroy_Proc Function used by the prg_mapping package to destroy a value stored in it. This can be PRGC_NIL, in which case values are not destroyed.

Return Type

PrgT_Mapping_Handle

The created mapping (or PRGC_NIL if something prevented the creation)

prg_mapping.h

Details

Used to create a mapping data structure that can be used to search a value or its key in O(log(n)) (where n is the number of stored elements).

Keys and values are represented by void * in this package.

The creation function takes three parameter functions to tailor its behavior to the specificity of the keys and values:

/* Given a value, returns the corresponding key */
void * PrgT_Mapping_Key_Of_Value_Proc (void * value);
/* return 1 if keya < keyb, 0 otherwise */
int PrgT_Mapping_Key_Lessthan_Proc (void * key_a, void * key_b);
/* destroy the provided value */
void PrgT_Mapping_Value_Destroy_Proc (void * value_ptr);

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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