From 2a16021425dab995e902d133b060ebcf6c59a00c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 28 Apr 2011 06:02:12 +0000 Subject: More future-proof collection APIs. Make all iterator actions occur through a collection specific function. Verbose, and a low of API, but allows for the possibility of different collection implementation types (given a choice between verbosity and no type safety, I'll take verbosity). git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@3211 a436a847-0d15-0410-975c-d299462d15a1 --- src/collections.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/collections.c') diff --git a/src/collections.c b/src/collections.c index 254d406..d8f5e1b 100644 --- a/src/collections.c +++ b/src/collections.c @@ -26,7 +26,6 @@ slv2_collection_new(GDestroyNotify destructor) return g_sequence_new(destructor); } -SLV2_API void slv2_collection_free(SLV2Collection coll) { @@ -34,14 +33,12 @@ slv2_collection_free(SLV2Collection coll) g_sequence_free((GSequence*)coll); } -SLV2_API unsigned slv2_collection_size(SLV2Collection coll) { return (coll ? g_sequence_get_length((GSequence*)coll) : 0); } -SLV2_API void* slv2_collection_get_at(SLV2Collection coll, unsigned index) { @@ -53,14 +50,12 @@ slv2_collection_get_at(SLV2Collection coll, unsigned index) } } -SLV2_API SLV2Iter slv2_collection_begin(SLV2Collection collection) { return collection ? g_sequence_get_begin_iter(collection) : NULL; } -SLV2_API void* slv2_collection_get(SLV2Collection collection, SLV2Iter i) @@ -70,14 +65,12 @@ slv2_collection_get(SLV2Collection collection, /* Constructors */ -SLV2_API SLV2ScalePoints slv2_scale_points_new(void) { return slv2_collection_new((GDestroyNotify)slv2_scale_point_free); } -SLV2_API SLV2Values slv2_values_new(void) { @@ -133,7 +126,7 @@ SLV2_API bool slv2_values_contains(SLV2Values list, SLV2Value value) { - SLV2_FOREACH(i, list) + SLV2_FOREACH(values, i, list) if (slv2_value_equals(slv2_values_get(list, i), value)) return true; @@ -142,14 +135,12 @@ slv2_values_contains(SLV2Values list, SLV2Value value) /* Iterator */ -SLV2_API SLV2Iter slv2_iter_next(SLV2Iter i) { return g_sequence_iter_next((GSequenceIter*)i); } -SLV2_API bool slv2_iter_end(SLV2Iter i) { @@ -175,6 +166,18 @@ prefix##_get(CT collection, SLV2Iter i) { \ return (ET)slv2_collection_get(collection, i); \ } \ \ +SLV2_API \ +SLV2Iter \ +prefix##_next(CT collection, SLV2Iter i) { \ + return slv2_iter_next(i); \ +} \ +\ +SLV2_API \ +bool \ +prefix##_is_end(CT collection, SLV2Iter i) { \ + return slv2_iter_end(i); \ +} \ +\ SLV2_DEPRECATED \ SLV2_API \ ET \ -- cgit v1.2.1