Added a function to reset the enumerator of a linked list.
authorTobias Brunner <tobias@strongswan.org>
Thu, 19 May 2011 16:13:38 +0000 (18:13 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 6 Jul 2011 07:43:45 +0000 (09:43 +0200)
src/libstrongswan/utils/linked_list.c
src/libstrongswan/utils/linked_list.h

index a44bcc1..67cb821 100644 (file)
@@ -175,6 +175,12 @@ METHOD(linked_list_t, create_enumerator, enumerator_t*,
        return &enumerator->enumerator;
 }
 
+METHOD(linked_list_t, reset_enumerator, void,
+          private_linked_list_t *this, private_enumerator_t *enumerator)
+{
+       enumerator->current = NULL;
+}
+
 METHOD(iterator_t, iterator_get_count, int,
           private_iterator_t *this)
 {
@@ -727,6 +733,7 @@ linked_list_t *linked_list_create()
                        .get_count = _get_count,
                        .create_iterator = _create_iterator,
                        .create_enumerator = _create_enumerator,
+                       .reset_enumerator = (void*)_reset_enumerator,
                        .get_first = _get_first,
                        .get_last = _get_last,
                        .find_first = (void*)_find_first,
index 8580427..9d4267e 100644 (file)
@@ -85,6 +85,13 @@ struct linked_list_t {
        enumerator_t* (*create_enumerator)(linked_list_t *this);
 
        /**
+        * Resets the enumerator's current position to the beginning of the list.
+        *
+        * @param enumerator    enumerator to reset
+        */
+       void (*reset_enumerator)(linked_list_t *this, enumerator_t *enumerator);
+
+       /**
         * Inserts a new item at the beginning of the list.
         *
         * @param item          item value to insert in list