

If you don\textquotesingle{}t know how to create lists see \mbox{\hyperlink{eina_list_01_example_page}{Adding elements to Eina\+\_\+\+List}}.

We start out with code that should be familiar by now\+: 
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#include <stdio.h>}
\textcolor{preprocessor}{#include <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc, \textcolor{keywordtype}{char} **argv)
\{
   (void)argc;
   (void)argv;
   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *list = NULL, *r\_list;
   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *l;
   \mbox{\hyperlink{struct__Eina__Iterator}{Eina\_Iterator}} *itr;
   \textcolor{keywordtype}{void} *list\_data;

   \mbox{\hyperlink{group__Eina__Main__Group_gafee4bfc0e509b6ffed6598edf6f4b3de}{eina\_init}}();

   list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, \textcolor{stringliteral}{"caprica"});
   list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, \textcolor{stringliteral}{"sagitarius"});
   list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, \textcolor{stringliteral}{"aerilon"});
   list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, \textcolor{stringliteral}{"gemenon"});

\end{DoxyCodeInclude}


You can move elements around in a list using \mbox{\hyperlink{group__Eina__List__Group_ga46a38e2bf6b9a52b7a5dd17c63ca5f60}{eina\+\_\+list\+\_\+move()}} or using \mbox{\hyperlink{group__Eina__List__Group_ga1037e7ab9d39bece24d864526332828c}{eina\+\_\+list\+\_\+promote\+\_\+list()}} and \mbox{\hyperlink{group__Eina__List__Group_ga082644881a2333bd16208c00931703cd}{eina\+\_\+list\+\_\+demote\+\_\+list()}} which move a list node to the head and end of the list respectively\+: 
\begin{DoxyCodeInclude}

   list = \mbox{\hyperlink{group__Eina__List__Group_ga1037e7ab9d39bece24d864526332828c}{eina\_list\_promote\_list}}(list, \mbox{\hyperlink{group__Eina__List__Group_gad4a1e3b0fdecd8ed4cb2ff592ceeb553}{eina\_list\_nth\_list}}(list, 2))
      ;
   list = \mbox{\hyperlink{group__Eina__List__Group_ga082644881a2333bd16208c00931703cd}{eina\_list\_demote\_list}}(list, \mbox{\hyperlink{group__Eina__List__Group_gad4a1e3b0fdecd8ed4cb2ff592ceeb553}{eina\_list\_nth\_list}}(list, 2));

\end{DoxyCodeInclude}


Removing elements from a list can be done with ease\+: 
\begin{DoxyCodeInclude}

   list = \mbox{\hyperlink{group__Eina__List__Group_ga7c0c6e07aa592a1cb2e010049a718035}{eina\_list\_remove}}(list, \textcolor{stringliteral}{"sagitarius"});

\end{DoxyCodeInclude}


To replace an element in the list it is not necessary to remove it and then re-\/add with the new value, it is possible to just change the value of a node\+: 
\begin{DoxyCodeInclude}

   l = \mbox{\hyperlink{group__Eina__List__Group_ga860144725b63d93b8f84cdf1d816bda8}{eina\_list\_data\_find\_list}}(list, \textcolor{stringliteral}{"aerilon"});
   \mbox{\hyperlink{group__Eina__List__Group_ga213776ffa28b780440da26f673917687}{eina\_list\_data\_set}}(l, \textcolor{stringliteral}{"aquarius"});

\end{DoxyCodeInclude}


We will now take a peek to see if the list still has the right number of elements\+: 
\begin{DoxyCodeInclude}

   printf(\textcolor{stringliteral}{"size: %d\(\backslash\)n"}, \mbox{\hyperlink{group__Eina__List__Group_ga301729054a498a2df09a5f1dd760697e}{eina\_list\_count}}(list));

\end{DoxyCodeInclude}


Now that the list is in alphabetical order let\textquotesingle{}s create a copy of it in reverse order and print every element to see if worked as expected\+: 
\begin{DoxyCodeInclude}

   r\_list = \mbox{\hyperlink{group__Eina__List__Group_ga67cb29eef0bf0a3cb2cc160ae506a07f}{eina\_list\_reverse\_clone}}(list);

   itr = \mbox{\hyperlink{group__Eina__List__Group_gabcfb6a861aa7c0db0ee36252ac2a254d}{eina\_list\_iterator\_new}}(r\_list);
   \mbox{\hyperlink{group__Eina__Iterator__Group_gac7314580e18868ef229f5d2814562794}{EINA\_ITERATOR\_FOREACH}}(itr, list\_data)
     printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, (\textcolor{keywordtype}{char}*)list\_data);
   \mbox{\hyperlink{group__Eina__Iterator__Group_gaf9261991a4b05dc63e3401278a3281f8}{eina\_iterator\_free}}(itr);

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
Always remember to free your iterators when done using them.
\end{DoxyNote}
And as always release memory and shutdown eina before ending\+: 
\begin{DoxyCodeInclude}

   \mbox{\hyperlink{group__Eina__List__Group_ga608bd2fbf06293a1b794648990703ab4}{eina\_list\_free}}(list);
   \mbox{\hyperlink{group__Eina__List__Group_ga608bd2fbf06293a1b794648990703ab4}{eina\_list\_free}}(r\_list);

   \mbox{\hyperlink{group__Eina__Main__Group_ga2c8b4020427108a30c44707af22c99d3}{eina\_shutdown}}();

   \textcolor{keywordflow}{return} 0;
\}

\end{DoxyCodeInclude}


The full source code can be found on the examples folder on the \mbox{\hyperlink{eina_list_03_c}{eina\+\_\+list\+\_\+03.c}} file. 