Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

jackutea/cdictionary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

C Dictionary

  • Add / TryGet / Remove
  • Key: long, Value: void*
  • One .h File
  • Freeze Capacity

Quick Start

void main() {
 // New
 Dictionary* dict = Dictionary_New(1000);
 // Add
 Dictionary_Add(dict, 1, "hello");
 int *value1 = malloc(sizeof(int));
 *value1 = 123;
 Dictionary_Add(dict, 2, value1);
 // Get
 void* outV1;
 bool succ = Dictionary_TryGet(dict, 1, &outV1);
 if (succ) {
 printf("Value1: %s\n", (char*)outV1);
 }
 void *outV2;
 succ = Dictionary_TryGet(dict, 2, &outV2);
 if (succ) {
 printf("Value2: %d\n", *(int*)(outV2));
 }
 // Remove
 succ = Dictionary_Remove(dict, 1);
 if (succ) {
 printf("Remove success\n");
 }
 succ = Dictionary_TryGet(dict, 1, &outV1);
 if (succ) {
 printf("Value1: %s\n", (char*)outV1);
 } else {
 printf("Value1 not found\n");
 }
 // Free
 free(value1);
 Dictionary_Free(dict);
 
}

About

πŸͺ‘C Dictionary

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /