Add a linked list constructor initializing from an enumerator
This commit is contained in:
@@ -572,3 +572,22 @@ linked_list_t *linked_list_create()
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
/*
|
||||
* See header.
|
||||
*/
|
||||
linked_list_t *linked_list_create_from_enumerator(enumerator_t *enumerator)
|
||||
{
|
||||
linked_list_t *list;
|
||||
void *item;
|
||||
|
||||
list = linked_list_create();
|
||||
|
||||
while (enumerator->enumerate(enumerator, &item))
|
||||
{
|
||||
list->insert_last(list, item);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user