-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* maint: rebase -i: abort cleanly if the editor fails to launch technical-docs: document hash API api-strbuf.txt: fix typos and document launch_editor()
- Loading branch information
Showing
3 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,52 @@ | ||
hash API | ||
======== | ||
|
||
Talk about <hash.h> | ||
The hash API is a collection of simple hash table functions. Users are expected | ||
to implement their own hashing. | ||
|
||
(Linus) | ||
Data Structures | ||
--------------- | ||
|
||
`struct hash_table`:: | ||
|
||
The hash table structure. The `array` member points to the hash table | ||
entries. The `size` member counts the total number of valid and invalid | ||
entries in the table. The `nr` member keeps track of the number of | ||
valid entries. | ||
|
||
`struct hash_table_entry`:: | ||
|
||
An opaque structure representing an entry in the hash table. The `hash` | ||
member is the entry's hash key and the `ptr` member is the entry's | ||
value. | ||
|
||
Functions | ||
--------- | ||
|
||
`init_hash`:: | ||
|
||
Initialize the hash table. | ||
|
||
`free_hash`:: | ||
|
||
Release memory associated with the hash table. | ||
|
||
`insert_hash`:: | ||
|
||
Insert a pointer into the hash table. If an entry with that hash | ||
already exists, a pointer to the existing entry's value is returned. | ||
Otherwise NULL is returned. This allows callers to implement | ||
chaining, etc. | ||
|
||
`lookup_hash`:: | ||
|
||
Lookup an entry in the hash table. If an entry with that hash exists | ||
the entry's value is returned. Otherwise NULL is returned. | ||
|
||
`for_each_hash`:: | ||
|
||
Call a function for each entry in the hash table. The function is | ||
expected to take the entry's value as its only argument and return an | ||
int. If the function returns a negative int the loop is aborted | ||
immediately. Otherwise, the return value is accumulated and the sum | ||
returned upon completion of the loop. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters