- fixed alot of bugs in child_proposal

- near to working state ;-)
This commit is contained in:
Martin Willi
2006-02-08 15:25:34 +00:00
parent 384efc76d5
commit c06dbbabd1
29 changed files with 1233 additions and 674 deletions
+26 -2
View File
@@ -360,6 +360,23 @@ static int get_count(private_linked_list_t *this)
return this->count;
}
/**
* Implementation of linked_list_t.call_on_items.
*/
static void call_on_items(private_linked_list_t *this, void(*func)(void*))
{
iterator_t *iterator;
void *item;
iterator = this->public.create_iterator(&(this->public),TRUE);
while (iterator->has_next(iterator))
{
iterator->current(iterator, &item);
(*func)(item);
}
iterator->destroy(iterator);
}
/**
* Implementation of linked_list_t.insert_first.
@@ -408,7 +425,10 @@ static status_t remove_first(private_linked_list_t *this, void **item)
}
this->first = element->next;
*item = element->value;
if (item != NULL)
{
*item = element->value;
}
this->count--;
@@ -478,7 +498,10 @@ static status_t remove_last(private_linked_list_t *this, void **item)
}
this->last = element->previous;
*item = element->value;
if (item != NULL)
{
*item = element->value;
}
this->count--;
@@ -649,6 +672,7 @@ linked_list_t *linked_list_create()
this->public.get_count = (int (*) (linked_list_t *)) get_count;
this->public.create_iterator = (iterator_t * (*) (linked_list_t *,bool )) create_iterator;
this->public.call_on_items = (void (*) (linked_list_t *, void(*func)(void*)))call_on_items;
this->public.get_first = (status_t (*) (linked_list_t *, void **item)) get_first;
this->public.get_last = (status_t (*) (linked_list_t *, void **item)) get_last;
this->public.insert_first = (void (*) (linked_list_t *, void *item)) insert_first;
+19 -3
View File
@@ -64,6 +64,22 @@ struct linked_list_t {
* @return new iterator_t object
*/
iterator_t * (*create_iterator) (linked_list_t *linked_list, bool forward);
/**
* @brief Call a function with list element as argument.
*
* This method accepts a function, which will be called for
* each list element once. The function must accept the list
* element as the first argument. Handy for destruction of
* list elements.
*
* @todo Additional vararg which are passed to the
* function would be nice...
*
* @param linked_list calling object
* @param func function to call
*/
void (*call_on_items) (linked_list_t *linked_list, void(*func)(void*));
/**
* @brief Inserts a new item at the beginning of the list.
@@ -77,7 +93,7 @@ struct linked_list_t {
* @brief Removes the first item in the list and returns its value.
*
* @param linked_list calling object
* @param[out] item returned value of first item
* @param[out] item returned value of first item, or NULL
* @return
* - SUCCESS
* - NOT_FOUND, if list is empty
@@ -143,7 +159,7 @@ struct linked_list_t {
* @brief Removes the last item in the list and returns its value.
*
* @param linked_list calling object
* @param[out] item item returned value of last item
* @param[out] item returned value of last item, or NULL
* @return
* - SUCCESS
* - NOT_FOUND if list is empty
@@ -154,7 +170,7 @@ struct linked_list_t {
* @brief Returns the value of the last list item without removing it.
*
* @param linked_list calling object
* @param[out] item item returned value of last item
* @param[out] item returned value of last item
* @return
* - SUCCESS
* - NOT_FOUND if list is empty