74 inline void *
add(
const uint8_t *key,
size_t key_length,
75 const uint8_t *data,
size_t data_length) {
76 return teoMapAdd(map, key, key_length, data, data_length);
79 inline void *
add(
const std::string& key,
const std::string& data) {
80 return add((
const uint8_t *)key.c_str(), key.size() + 1,
81 (
const uint8_t *)data.c_str(), data.size() + 1);
85 void *
add(
const std::string& key,
const D& data) {
86 return add((
const uint8_t*)key.c_str(), key.size() + 1,
87 (
const uint8_t *)&data,
sizeof(D));
90 template<
typename K,
typename D>
91 void *
add(
const K& key,
const D& data) {
92 return add((
const uint8_t*)&key,
sizeof(K),
93 (
const uint8_t *)&data,
sizeof(D));
98 inline void *
get(
const uint8_t *key,
size_t key_length,
size_t *data_length) {
99 return teoMapGet(map, key, key_length, data_length);
102 inline void *
get(
const std::string& key,
size_t *data_length) {
103 return get((
const uint8_t *)key.c_str(), key.size() + 1, data_length);
107 void *
get(
const K& key,
size_t *data_length) {
108 return get((
const uint8_t *)&key,
sizeof(K), data_length);
113 inline int del(
const uint8_t *key,
size_t key_length) {
117 inline int del(
const std::string& key) {
118 return del((
const uint8_t *)key.c_str(), key.size() + 1);
123 return del((
const uint8_t *)&key,
sizeof(K));
154 return teoMapIteratorElement(it);
160 return (D *)teoMapIteratorElementKey(el, key_length);
166 return (D *)teoMapIteratorElementData(el, data_length);
uint8_t * teoMapGet(teoMap *map, const uint8_t *key, size_t key_length, size_t *data_length)
Get key data from hash table.
Definition: map.c:345
teoMapIterator * iteratorReverse()
Definition: map.hpp:133
int(* teoMapForeachFunction)(teoMap *m, int idx, teoMapElementData *d, void *user_data)
Definition: map.h:228
teoMap * teoMapNew(size_t size, int auto_resize_f)
Create new map.
Definition: map.c:65
int teoMapDelete(teoMap *map, const uint8_t *key, size_t key_length)
Delete keys element from map.
Definition: map.c:373
teoMapIterator * teoMapIteratorReverseNew(teoMap *map)
Create new map reverse iterator.
Definition: map.c:432
int iteratorFree(teoMapIterator *it)
Definition: map.hpp:148
teoMapIterator * teoMapIteratorNew(teoMap *map)
Create new map iterator.
Definition: map.c:402
virtual ~Map()
Definition: map.hpp:56
Map()
Definition: map.hpp:50
teoMapElementData * teoMapIteratorNext(teoMapIterator *map_it)
Get next maps element.
Definition: map.c:477
int teoMapForeach(teoMap *m, teoMapForeachFunction callback, void *user_data)
Loop through map and call callback function with index and data in parameters.
Definition: map.c:537
void * getFirst(size_t *data_length)
Definition: map.hpp:68
size_t size()
Definition: map.hpp:60
D * mapItElKey(teoMapElementData *el, size_t *key_length=NULL)
Definition: map.hpp:159
teoMapIterator * iterator()
Definition: map.hpp:128
size_t teoMapSize(teoMap *map)
Get number of elements in TR-UPD map.
Definition: map.c:54
uint8_t * teoMapAdd(teoMap *map, const uint8_t *key, size_t key_length, const uint8_t *data, size_t data_length)
Add (or update) key data to the map.
Definition: map.c:282
teoMapElementData * iteratorNext(teoMapIterator *it)
Definition: map.hpp:138
void * add(const uint8_t *key, size_t key_length, const uint8_t *data, size_t data_length)
Definition: map.hpp:74
void teoMapClear(teoMap *map)
Definition: map.c:171
D * mapItElData(teoMapElementData *el, size_t *data_length=NULL)
Definition: map.hpp:165
void teoMapDestroy(teoMap *map)
Destroy map.
Definition: map.c:161
int teoMapIteratorFree(teoMapIterator *map_it)
Destroy map iterator.
Definition: map.c:462
uint8_t * teoMapGetFirst(teoMap *map, size_t *data_length)
Get first available element from hash table.
Definition: map.c:246
void * add(const K &key, const D &data)
Definition: map.hpp:91
teoMapElementData * mapItEl(teoMapIterator *it)
Definition: map.hpp:153
int del(const K &key)
Definition: map.hpp:122
void mapClear()
Definition: map.hpp:64
int del(const uint8_t *key, size_t key_length)
Definition: map.hpp:113
void * add(const std::string &key, const std::string &data)
Definition: map.hpp:79
void * add(const std::string &key, const D &data)
Definition: map.hpp:85
teoMapElementData * teoMapIteratorPrev(teoMapIterator *map_it)
Get previous maps element.
Definition: map.c:506
Map(size_t size, int auto_resize_f)
Definition: map.hpp:51
int del(const std::string &key)
Definition: map.hpp:117
#define HASH_TABLE_SIZE
Definition: map.h:45
teoMapElementData * iterator_prev(teoMapIterator *it)
Definition: map.hpp:143