Add pmap_remove().
This commit is contained in:
parent
23c3575f0f
commit
ff58a6100f
|
@ -1,5 +1,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "pmap.h"
|
||||
|
||||
static void append(void* mapp, void* left, void* right)
|
||||
|
@ -56,6 +57,23 @@ void pmap_add(void* mapp, void* left, void* right)
|
|||
append(map, left, right);
|
||||
}
|
||||
|
||||
void pmap_remove(void* mapp, void* left, void* right)
|
||||
{
|
||||
struct pmap* map = mapp;
|
||||
int i;
|
||||
|
||||
for (i=0; i<map->count; i++)
|
||||
{
|
||||
struct pmap_node* node = &map->item[i];
|
||||
if ((node->left == left) && (node->right == right))
|
||||
{
|
||||
memmove(node, node+1, sizeof(*node) * (map->count - i - 1));
|
||||
map->count--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* pmap_findleft(void* mapp, void* left)
|
||||
{
|
||||
struct pmap* map = mapp;
|
||||
|
|
|
@ -25,6 +25,7 @@ struct pmap
|
|||
|
||||
extern void pmap_put(void* map, void* left, void* right);
|
||||
extern void pmap_add(void* map, void* left, void* right);
|
||||
extern void pmap_remove(void* map, void* left, void* right);
|
||||
extern void* pmap_findleft(void* map, void* left);
|
||||
extern void* pmap_findright(void* map, void* right);
|
||||
|
||||
|
|
Loading…
Reference in a new issue