X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=doc%2Fhtml%2Flinkhash_8h.html;h=772ea22bf2c11619d21abd98aa63d753f15641bd;hb=bc5c17d2ffbbbafa4acc7390f3a0a960b3efb29c;hp=45569a76181761917d5aa8f3738856b52f2e4398;hpb=4596746bf7d656206a824f7e7ec629152773fd6c;p=platform%2Fupstream%2Fjson-c.git diff --git a/doc/html/linkhash_8h.html b/doc/html/linkhash_8h.html index 45569a7..772ea22 100644 --- a/doc/html/linkhash_8h.html +++ b/doc/html/linkhash_8h.html @@ -1,740 +1,1155 @@ - - + + + + + json-c: linkhash.h File Reference - - - - - +
- +
#define LH_PRIME   0x9e370001UL #define LH_LOAD_FACTOR   0.66
-
-
+
+

The fraction of filled hash buckets until an insert will cause the table to be resized. This can range from just above 0 up to 1.0.

-

-golden prime used in hash functions

-

-


Typedef Documentation

- + +
- +
typedef void( lh_entry_free_fn)(struct lh_entry *e) #define LH_PRIME   0x9e370001UL
+
+

golden prime used in hash functions

+ +
-
+

Typedef Documentation

+ +
+
+ + + + +
typedef void( lh_entry_free_fn)(struct lh_entry *e)
+
+

callback function prototypes

-

-callback function prototypes

-

- +

+
- +
typedef int( lh_equal_fn)(const void *k1, const void *k2) typedef int( lh_equal_fn)(const void *k1, const void *k2)
+
+

callback function prototypes

+
-
+
+ +
+
+ + + + +
typedef unsigned long( lh_hash_fn)(const void *k)
+
+

callback function prototypes

-

-callback function prototypes

-

- +

+
- +
typedef unsigned long( lh_hash_fn)(const void *k) typedef struct lh_table lh_table
+
+
-
+
+

Function Documentation

+ +
+
+ + + + + + + + +
int json_global_set_string_hash (const int h)
+
+

This function sets the hash function to be used for strings. Must be one of the JSON_C_STR_HASH_* values.

+
Returns
0 - ok, -1 if parameter was invalid
-

-callback function prototypes

-

-


Function Documentation

- +
+
+ + + + + +
- + - - + + + +
void lh_abort static void* lh_entry_k (const char *  msg, const struct lh_entrye)
+
+inlinestatic
+
+

Return a non-const version of lh_entry.k.

+

lh_entry.k is const to indicate and help ensure that linkhash itself doesn't modify it, but callers are allowed to do what they want with it.

+
See Also
lh_entry_k_is_constant()
+ +

References lh_entry::k.

+ +
+
+ +
+
+ + + + + +
+ - + + + + - - +
static int lh_entry_k_is_constant (const struct lh_entrye)   ... 
+
+inlinestatic
+
+

Returns 1 if the key for the given entry is constant, and thus does not need to be freed when the lh_entry is freed.

+
See Also
lh_table_insert_w_hash()
+ +

References lh_entry::k_is_constant.

+ +
+
+ +
+
+ + + + + +
+ + + + + - -
static struct lh_entry* lh_entry_next (const struct lh_entrye) )
+
+staticread
+
+

Return the next element, or NULL if there is no next element.

+
See Also
lh_table_head()
+
+lh_entry_prev()
+ +

References lh_entry::next.

+ +
-
+ +
+
+ + + + + +
+ + + + + + + + +
static struct lh_entry* lh_entry_prev (const struct lh_entrye)
+
+staticread
+
+

Return the previous element, or NULL if there is no previous element.

+
See Also
lh_table_head()
+
+lh_entry_next()
-

+

References lh_entry::prev.

-

- +

+
+ + + + + +
- + - - + + - - + + - +
int lh_char_equal static void lh_entry_set_val (const void *  k1, struct lh_entrye,
const void *  k2 void * newval 
)
- -
+
+inlinestatic
+
+

Change the value for an entry. The caller is responsible for freeing the previous value.

-

+

References lh_entry::v.

-

- + +

+ + + + + +
- + - - - + +
unsigned long lh_char_hash static void* lh_entry_v (const void *  k  ) const struct lh_entrye)
- -
+
+inlinestatic
+
+

Return a non-const version of lh_entry.v.

+

v is const to indicate and help ensure that linkhash itself doesn't modify it, but callers are allowed to do what they want with it.

-

+

References lh_entry::v.

-

- + +

+ + + + + +
- + - - + + - - + + + + + + + + +
struct lh_table* lh_kchar_table_new static unsigned long lh_get_hash (int  size, const struct lh_tablet,
const char *  name, const void * k 
)
+
+inlinestatic
+
+

Calculate the hash of a key for a given table.

+

This is an extension to support functions that need to calculate the hash several times and allows them to do it just once and then pass in the hash to all utility functions. Depending on use case, this can be a considerable performance improvement.

+
Parameters
+ + + +
tthe table (used to obtain hash function)
ka pointer to the key to lookup
+
+
+
Returns
the key's hash
+ +

References lh_table::hash_fn.

+ +
+
+ +
+
+ + +
+ + + + + + - - + + - +
struct lh_table* lh_kchar_table_new (int size,
lh_entry_free_fn free_fn lh_entry_free_fnfree_fn 
) [read]
- -
- -

-Convenience function to create a new linkhash table with char keys.

Parameters:
- - - - + + + +
size initial table size.
name table name.
free_fn callback function used to free memory for entries.
+read
+
+

Convenience function to create a new linkhash table with char keys.

+
Parameters
+ + +
sizeinitial table size.
free_fncallback function used to free memory for entries.
+
-
Returns:
a pointer onto the linkhash table.
+
Returns
On success, a pointer to the new linkhash table is returned. On error, a null pointer is returned.
-

- + +

+ + + + + +
- + - - + + - - + + + + + + + + +
struct lh_table* lh_kptr_table_new struct lh_table* lh_kptr_table_new (int  size, int size,
const char *  name, lh_entry_free_fnfree_fn 
)
+
+read
+
+

Convenience function to create a new linkhash table with ptr keys.

+
Parameters
+ + + +
sizeinitial table size.
free_fncallback function used to free memory for entries.
+
+
+
Returns
On success, a pointer to the new linkhash table is returned. On error, a null pointer is returned.
+ +
+
+ +
+
+ + + + + + - - + + - +
int lh_table_delete (struct lh_tablet,
lh_entry_free_fn free_fn const void * k 
) [read]
-
-
- -

-Convenience function to create a new linkhash table with ptr keys.

Parameters:
- - - - +
+

Delete a record from the table.

+

If a callback free function is provided then it is called for the for the item being deleted.

+
Parameters
+
size initial table size.
name table name.
free_fn callback function used to free memory for entries.
+ +
tthe table to delete from.
ka pointer to the key to delete.
+
-
Returns:
a pointer onto the linkhash table.
+
Returns
0 if the item was deleted.
+
+-1 if it was not found.
-

- + +

- + - - + + - - + + - +
int lh_ptr_equal int lh_table_delete_entry (const void *  k1, struct lh_tablet,
const void *  k2 struct lh_entrye 
)
-
-
- -

+

+

Delete a record from the table.

+

If a callback free function is provided then it is called for the for the item being deleted.

+
Parameters
+ + + +
tthe table to delete from.
ea pointer to the entry to delete.
+
+
+
Returns
0 if the item was deleted.
+
+-1 if it was not found.
-

- + +

- + - - - + +
unsigned long lh_ptr_hash void lh_table_free (const void *  k  ) struct lh_tablet)
+
+

Free a linkhash table.

+

If a lh_entry_free_fn callback free function was provided then it is called for all entries in the table.

+
Parameters
+ + +
ttable to free.
+
+
+ +
-
+ +
+
+ + + + + +
+ + + + + + + + +
static struct lh_entry* lh_table_head (const lh_tablet)
+
+staticread
+
+

Return the first entry in the lh_table.

+
See Also
lh_entry_next()
+ +

References lh_table::head.

-

-Pre-defined hash and equality functions

-

- +

+
- + - - + + - - + + + + + + + + - +
int lh_table_delete int lh_table_insert (struct lh_table t, struct lh_tablet,
const void *  k const void * k,
const void * v 
)
-
-
- -

-Delete a record from the table. If a callback free function is provided then it is called for the for the item being deleted.

Parameters:
- - - +
+

Insert a record into the table.

+
Parameters
+
t the table to delete from.
k a pointer to the key to delete.
+ + +
tthe table to insert into.
ka pointer to the key to insert.
va pointer to the value to insert.
+
-
Returns:
0 if the item was deleted.

--1 if it was not found.

+
Returns
On success, 0 is returned. On error, a negative value is returned.
-

- + +

- + - - + + + + + + + + + + + + + + - - + + + + + + + + - +
int lh_table_delete_entry int lh_table_insert_w_hash (struct lh_table t, struct lh_tablet,
const void * k,
const void * v,
struct lh_entry e const unsigned long h,
const unsigned opts 
)
-
-
- -

-Delete a record from the table. If a callback free function is provided then it is called for the for the item being deleted.

Parameters:
- - - +
+

Insert a record into the table using a precalculated key hash.

+

The hash h, which should be calculated with lh_get_hash() on k, is provided by the caller, to allow for optimization when multiple operations with the same key are known to be needed.

+
Parameters
+
t the table to delete from.
e a pointer to the entry to delete.
+ + + + +
tthe table to insert into.
ka pointer to the key to insert.
va pointer to the value to insert.
hhash value of the key to insert
optsif set to JSON_C_OBJECT_ADD_CONSTANT_KEY, sets lh_entry.k_is_constant so t's free function knows to avoid freeing the key.
+
-
Returns:
0 if the item was deleted.

--1 if it was not found.

-

- + +

- + - - - + +
void lh_table_free int lh_table_length (struct lh_table t  ) struct lh_tablet)
-
-
- -

-Free a linkhash table. If a callback free function is provided then it is called for all entries in the table.

Parameters:
- - -
t table to free.
-
+
+

Return the number of entries in the table.

-

- + +

+ + +
- + - - + + - - - - - - - - + + - +
int lh_table_insert struct lh_entry* lh_table_lookup_entry (struct lh_table t, struct lh_tablet,
void *  k,
const void *  v const void * k 
)
- -
- -

-Insert a record into the table.

Parameters:
- - - - + + + +
t the table to insert into.
k a pointer to the key to insert.
v a pointer to the value to insert.
+read
+
+

Lookup a record in the table.

+
Parameters
+ + +
tthe table to lookup
ka pointer to the key to lookup
+
+
Returns
a pointer to the record structure of the value or NULL if it does not exist.
-

- + +

+ + +
- + - - + + - - + + + + + + + + - +
const void* lh_table_lookup struct lh_entry* lh_table_lookup_entry_w_hash (struct lh_table t, struct lh_tablet,
const void *  k const void * k,
const unsigned long h 
)
- -
- -

-Lookup a record into the table

Parameters:
- - - + + + +
t the table to lookup
k a pointer to the key to lookup
+read
+
+

Lookup a record in the table using a precalculated key hash.

+

The hash h, which should be calculated with lh_get_hash() on k, is provided by the caller, to allow for optimization when multiple operations with the same key are known to be needed.

+
Parameters
+ + + +
tthe table to lookup
ka pointer to the key to lookup
hhash value of the key to lookup
+
-
Returns:
a pointer to the found value or NULL if it does not exist.
+
Returns
a pointer to the record structure of the value or NULL if it does not exist.
-

- + +

- + - - + + - - + + + + + + + + - +
struct lh_entry* lh_table_lookup_entry json_bool lh_table_lookup_ex (struct lh_table t, struct lh_tablet,
const void *  k const void * k,
void ** v 
) [read]
-
-
- -

-Lookup a record into the table.

Parameters:
- - - +
+

Lookup a record in the table.

+
Parameters
+
t the table to lookup
k a pointer to the key to lookup
+ + +
tthe table to lookup
ka pointer to the key to lookup
va pointer to a where to store the found value (set to NULL if it doesn't exist).
+
-
Returns:
a pointer to the record structure of the value or NULL if it does not exist.
+
Returns
whether or not the key was found
-

- + +

+ + +
- + - - - - - - - - + + - - + + - - + + - - + + - +
struct lh_table* lh_table_new struct lh_table* lh_table_new (int  size,
const char *  name, int size,
lh_entry_free_fn free_fn, lh_entry_free_fnfree_fn,
lh_hash_fn hash_fn, lh_hash_fnhash_fn,
lh_equal_fn equal_fn lh_equal_fnequal_fn 
) [read]
- -
- -

-Create a new linkhash table.

Parameters:
- - - - - - + + + +
size initial table size. The table is automatically resized although this incurs a performance penalty.
name the table name.
free_fn callback function used to free memory for entries when lh_table_free or lh_table_delete is called. If NULL is provided, then memory for keys and values must be freed by the caller.
hash_fn function used to hash keys. 2 standard ones are defined: lh_ptr_hash and lh_char_hash for hashing pointer values and C strings respectively.
equal_fn comparison function to compare keys. 2 standard ones defined: lh_ptr_hash and lh_char_hash for comparing pointer values and C strings respectively.
+read
+
+

Create a new linkhash table.

+
Parameters
+ + + + +
sizeinitial table size. The table is automatically resized although this incurs a performance penalty.
free_fncallback function used to free memory for entries when lh_table_free or lh_table_delete is called. If NULL is provided, then memory for keys and values must be freed by the caller.
hash_fnfunction used to hash keys. 2 standard ones are defined: lh_ptr_hash and lh_char_hash for hashing pointer values and C strings respectively.
equal_fncomparison function to compare keys. 2 standard ones defined: lh_ptr_hash and lh_char_hash for comparing pointer values and C strings respectively.
+
-
Returns:
a pointer onto the linkhash table.
+
Returns
On success, a pointer to the new linkhash table is returned. On error, a null pointer is returned.
-

- + +

- + - - + + - - + + - +
void lh_table_resize int lh_table_resize (struct lh_table t, struct lh_tablet,
int  new_size int new_size 
)
-
-
- -

+

+

Resizes the specified table.

+
Parameters
+ + + +
tPointer to table to resize.
new_sizeNew table size. Must be positive.
+
+
+
Returns
On success, 0 is returned. On error, a negative value is returned.
-

-


Generated on Fri Jul 31 10:58:15 2009 for json-c by  - -doxygen 1.5.8
+ + +