summaryrefslogtreecommitdiff
path: root/legacy/ecore/examples/list_example.c
blob: 2aa606aff8ed542dbecd4a46ac2b986323ed6347 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <Ecore_Data.h>

void print_list (Ecore_List *list) {
  char *list_item;

  printf("--- Current List ---\n");
  ecore_list_goto_first(list);
  while((list_item = (char*)ecore_list_next(list)) != NULL) {
    printf("\t%s\n", list_item);
  }
}

int main (int argc, char *argv[]) {
  Ecore_List *list;
  char *first  = "first";
  char *second = "second";
  char *last   = "last";

  list = ecore_list_new();

  ecore_list_append(list, last);    // Insert
  ecore_list_prepend(list, first);  // Add to front
  ecore_list_goto_index(list, 1);   // counted from 0
  ecore_list_insert(list, second);  // Insert before item at index 2
  print_list(list);

  ecore_list_destroy(list);

  return 0;
}