summaryrefslogtreecommitdiff
path: root/meme/mesh.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2014-09-12 17:20:43 (GMT)
committerWerner Almesberger <werner@almesberger.net>2014-09-12 17:20:43 (GMT)
commit7b7435012f7e510e08662463b0865327824e2ab9 (patch)
tree374a4071ce178b07eb1c1030ed191d939307bf03 /meme/mesh.c
parent29baa2745d7408a8bbe6088807e3467a11120855 (diff)
downloadmisc-7b7435012f7e510e08662463b0865327824e2ab9.zip
misc-7b7435012f7e510e08662463b0865327824e2ab9.tar.gz
misc-7b7435012f7e510e08662463b0865327824e2ab9.tar.bz2
meme/: abstract iteration over edges (edge_foreach)
This way, we can later remove "struct edge".
Diffstat (limited to 'meme/mesh.c')
-rw-r--r--meme/mesh.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/meme/mesh.c b/meme/mesh.c
index 39ee10c..9195885 100644
--- a/meme/mesh.c
+++ b/meme/mesh.c
@@ -36,7 +36,7 @@ static struct v *vhash[VHASH_TABLE];
static struct e *ehash[EHASH_TABLE];
-struct edge *edges = NULL;
+static struct edge *edges = NULL;
struct facet *facets = NULL;
@@ -104,6 +104,17 @@ void vertex_foreach_const(bool (*fn)(const struct vertex *v, void *user),
}
+void edge_foreach(bool (*fn)(const struct vertex *a, const struct vertex *b,
+ void *user), void *user)
+{
+ const struct edge *e;
+
+ for (e = edges; e; e = e->next)
+ if (fn(e->a, e->b, user))
+ return;
+}
+
+
static void edge_add(const struct vertex *a, const struct vertex *b)
{
const struct vertex *tmp;