Exemple #1
0
int main() 
{
    // Create list
    list_t list;
    list_create(&list, 5);

    // Insert elements
    //  9  8  7
    //  6  5  4
    //  3  2  1
    for (int i = 0; i < 9; ++i)
    {
        point_t* point = (point_t*) malloc(sizeof(point_t));
        point->x = i % 3;
        point->y = i / 3;
        point->cost = i;

        list_insert(list, 9 - i, point);
        //print_point(9 - i, point);
        print_point(point, 9 - i);
    }

    // Find element
    printf("\n");
    point_t* element;
    list_search(list, 2, &element);
    print_point(element, 2);

    // Traverse list
    printf("\n");
    list_walk(list, &print_point);

    // Remove element
    list_remove(list, 2, &element);
    printf("removed element has cost %d\n", element->cost);
    free(element);

    // Traverse list
    printf("\n");
    list_walk(list, &print_point);

    // Traverse list and change cost
    printf("\n");
    list_walk(list, (callback_t) &change_cost);
    list_walk(list, &print_point);

    // Clean up
    printf("\n");
    list_free(list, NULL);

    return 0;
}
void
mtv_channel_order_free_list(list_s *s)
{
	list_walk(s, (list_apply_cb)_channel_order_free);
	list_destroy(s);
	s = NULL;
}
Exemple #3
0
void image_map(image_map_callback *fn, void *opaque)
{
  /* Note that the callback signatures are identical, so we can cast. */

  list_walk(&list_anchor, (list_walk_callback *) fn, opaque);
}
Exemple #4
0
void wire_fin(void)
{
  /* inefficient: we walk list twice */

  list_walk(&LOCALS.anchor, (list_walk_callback *) fin_cb, NULL);
}