Quick actions

cmd+k|ctrl+k

Navigation

Languages

hash table

Snippet info

Language

Cpp

Visibility

public

Author

evine

Created

2016-10-22T14:20:45Z

Updated

2016-10-23T14:04:24Z

#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#define forI(index, length) \
for(uint64_t index = 0; index < (length); ++index)

#define CONCAT_(a, b) a##b
#define CONCAT(a, b) CONCAT_(a, b)

#include "misc_string.hpp"
#include "hash_table_core.hpp"

#define VAR_NAME int
#define VAR_TYPE int
#include "hash_table.hpp"


#define VAR_NAME float
#define VAR_TYPE float
#include "hash_table.hpp"


int main()
{
	hash_table_float test = hash_table_init_float();

	test.insert(string_init("ter0"), 3.0f);
	test.insert(string_init("ter1"), 3.0f);
	test.insert(string_init("ter2"), 3.0f);
	test.insert(string_init("ter3"), 3.0f);
	test.insert(string_init("ter15"), 3.0f);
	test.insert(string_init("ter5"), 3.0f);
	test.insert(string_init("ter6"), 72.3f);
	bool ye;
	float teg = test.get(string_init("ter6"), &ye);
	assert(ye);
	printf("Value: %g\n", teg);
	hash_print_table(&test);

	printf("Table size: %llu\n", test.size );
	
	test.remove(string_init("ter0"));
	test.remove(string_init("ter1"));
	test.remove(string_init("ter2"));
	test.remove(string_init("ter3"));
	test.remove(string_init("ter4"));
	test.remove(string_init("ter5"));
	test.remove(string_init("ter6"));

	hash_print_table(&test);
	
	return 0;
}
INFO