Xiqual 0.9.1

In file xitools/hash_newfromlist.c:

HashTable* hash_newfromlist

(List* l,
  ulong size,
  ulong load)

Turn a struct List into a struct HashTable.


Turn a struct List into a struct HashTable.

Every node from the list is converted into a hash node, then the list is freed. This function assumes that the nodes in the list all have data pointers pointing to a string. This pointer is copied and cleared to save a few allocations.

If no size is specified, twice the number of list elements will be assumed. Default load is two elements.

hash_new() is used to allocate the list. If you have need of larger nodes, you should iterate through your lists and do this yourself.

This function is useful after collecting the contents of a dictionary.

l - A list with nodes pointing their data elements to allocated spaces with strings.
- size Zero for default of twice the list size, or any number at least as large as the list. The size will be set to same as the list if you specify anything lower.
A hash table. If any allocations failed, they're silently ignored. You should check whether the count is the same as the list size. NULL if memory allocation of the table itself failed.
Ronny Bangsund
See Also:
hash_new(), HashTable, List

Alphabetic index

This page was generated with the help of DOC++.