Associative arrays/Creation/C: Difference between revisions
Content added Content deleted
(fixed the wiki-markup) |
mNo edit summary |
||
Line 7: | Line 7: | ||
A hash table can be implemented with the following. Because of this example's simplicity, it comes with some restrictions on use and capabilities: It can't be resized automatically, if you try to insert more values than its capacity it will freeze, the hashing function is very simple, etc. All are fixable with additional logic or using a library: |
A hash table can be implemented with the following. Because of this example's simplicity, it comes with some restrictions on use and capabilities: It can't be resized automatically, if you try to insert more values than its capacity it will freeze, the hashing function is very simple, etc. All are fixable with additional logic or using a library: |
||
<syntaxhighlight lang="с" |
<syntaxhighlight lang="с"> |
||
#include <stdio.h> |
|||
#include <stdlib.h> |
#include <stdlib.h> |
||
Line 50: | Line 51: | ||
printf("a => %s\n", hash_lookup(h, "a")); |
printf("a => %s\n", hash_lookup(h, "a")); |
||
return 0; |
return 0; |
||
} |
|||
</<syntaxhighlight> |
|||
==Libraries== |
==Libraries== |
||
Line 58: | Line 60: | ||
{{libheader|Judy}} |
{{libheader|Judy}} |
||
<syntaxhighlight lang="с" |
<syntaxhighlight lang="с"> |
||
#include <stdio.h> |
|||
#include <Judy.h> |
#include <Judy.h> |
||
Line 91: | Line 94: | ||
return 0; |
return 0; |
||
} |
|||
</syntaxhighlight> |
|||
{{libheader|Judy}} |
{{libheader|Judy}} |