From 30a9db17dc69f9f43c8c5fe51847252adbb220e2 Mon Sep 17 00:00:00 2001 From: Max Wash Date: Tue, 3 Feb 2026 14:43:35 +0000 Subject: [PATCH] ds: list: update iterator interface --- ds/include/blue/ds/list.h | 2 +- ds/list.c | 38 +++++++++++++++++++------------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/ds/include/blue/ds/list.h b/ds/include/blue/ds/list.h index 9678e6c..122e92e 100644 --- a/ds/include/blue/ds/list.h +++ b/ds/include/blue/ds/list.h @@ -56,7 +56,7 @@ BLUE_API void b_list_delete_all(b_list *q); BLUE_API void *b_list_entry_value(const b_list_entry *entry); BLUE_API b_iterator *b_list_begin(b_list *q); -BLUE_API b_iterator *b_list_cbegin(const b_list *q); +BLUE_API const b_iterator *b_list_cbegin(const b_list *q); B_DECLS_END; diff --git a/ds/list.c b/ds/list.c index ec50682..7ac1a2e 100644 --- a/ds/list.c +++ b/ds/list.c @@ -365,22 +365,7 @@ void *b_list_entry_value(const struct b_list_entry *entry) return entry ? entry->e_data : NULL; } -/*** VIRTUAL FUNCTIONS ********************************************************/ - -static void list_init(b_object *obj, void *priv) -{ - struct b_list_p *list = priv; -} - -static void list_fini(b_object *obj, void *priv) -{ - struct b_list_p *list = priv; - list_delete_all(list); -} - -/*** ITERATOR FUNCTIONS *******************************************************/ - -static b_iterator *iterable_begin(b_list *q) +b_iterator *b_list_begin(b_list *q) { b_list_iterator *it_obj = b_object_create(B_TYPE_LIST_ITERATOR); struct b_list_iterator_p *it @@ -399,7 +384,7 @@ static b_iterator *iterable_begin(b_list *q) return 0; } -static const b_iterator *iterable_cbegin(const b_list *q) +const b_iterator *b_list_cbegin(const b_list *q) { b_list_iterator *it_obj = b_object_create(B_TYPE_LIST_ITERATOR); struct b_list_iterator_p *it @@ -418,6 +403,21 @@ static const b_iterator *iterable_cbegin(const b_list *q) return 0; } +/*** VIRTUAL FUNCTIONS ********************************************************/ + +static void list_init(b_object *obj, void *priv) +{ + struct b_list_p *list = priv; +} + +static void list_fini(b_object *obj, void *priv) +{ + struct b_list_p *list = priv; + list_delete_all(list); +} + +/*** ITERATOR FUNCTIONS *******************************************************/ + static enum b_status iterator_move_next(const b_iterator *obj) { struct b_list_iterator_p *it @@ -493,8 +493,8 @@ B_TYPE_CLASS_DEFINITION_BEGIN(b_list) B_TYPE_CLASS_INTERFACE_END(b_object, B_TYPE_OBJECT) B_TYPE_CLASS_INTERFACE_BEGIN(b_iterable, B_TYPE_ITERABLE) - B_INTERFACE_ENTRY(it_begin) = iterable_begin; - B_INTERFACE_ENTRY(it_cbegin) = iterable_cbegin; + B_INTERFACE_ENTRY(it_begin) = b_list_begin; + B_INTERFACE_ENTRY(it_cbegin) = b_list_cbegin; B_TYPE_CLASS_INTERFACE_END(b_iterable, B_TYPE_ITERABLE) B_TYPE_CLASS_DEFINITION_END(b_list)