From b88d5f47a9c5ef877b83fe60f2b948df09e1526a Mon Sep 17 00:00:00 2001 From: erg Date: Fri, 24 Jul 2009 21:07:07 +0000 Subject: [PATCH] Add update operator so that a point map can be changed --- lib/common/pointset.c | 15 +++++++++++++++ lib/common/pointset.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/lib/common/pointset.c b/lib/common/pointset.c index 90b6dd0c8..157703b9d 100644 --- a/lib/common/pointset.c +++ b/lib/common/pointset.c @@ -194,6 +194,21 @@ void freePM(PointMap * ps) free(dp); } +int updatePM(PointMap * pm, int x, int y, int v) +{ + mpair *p; + mpair dummy; + int old; + + dummy.id.x = x; + dummy.id.y = y; + dummy.v = v; + p = dtinsert(pm, &dummy); + old = p->v; + p->v = v; + return old; +} + int insertPM(PointMap * pm, int x, int y, int v) { mpair *p; diff --git a/lib/common/pointset.h b/lib/common/pointset.h index 0f865598a..d1e98fa79 100644 --- a/lib/common/pointset.h +++ b/lib/common/pointset.h @@ -17,6 +17,9 @@ #ifndef _POINTSET_H #define _POINTSET_H 1 +#include +#include + #ifdef __cplusplus extern "C" { #endif @@ -50,6 +53,7 @@ extern "C" { extern void clearPM(PointMap *); extern void freePM(PointMap *); extern int insertPM(PointMap *, int, int, int); + extern int updatePM(PointMap * pm, int x, int y, int v); #undef extern #ifdef __cplusplus -- 2.40.0