\hypertarget{eina_iterator_01_8c-example}{}\section{eina\+\_\+iterator\+\_\+01.\+c}

\begin{DoxyCodeInclude}
\textcolor{comment}{//Compile with:}
\textcolor{comment}{//gcc -g eina\_iterator\_01.c -o eina\_iterator\_01 `pkg-config --cflags --libs eina`}

\textcolor{preprocessor}{#include <stdio.h>}

\textcolor{preprocessor}{#include <\mbox{\hyperlink{Eina_8h}{Eina.h}}>}

\textcolor{keyword}{static} \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\_Bool}}
print\_one(\textcolor{keyword}{const} \textcolor{keywordtype}{void} *container \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{void} *data, \textcolor{keywordtype}{void} *fdata 
      \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, (\textcolor{keywordtype}{char}*)data);
   \textcolor{keywordflow}{return} \mbox{\hyperlink{group__Eina__Types__Group_ga05c12dacc8b4058994df842b41be85fc}{EINA\_TRUE}};
\}

\textcolor{keyword}{static} \textcolor{keywordtype}{void}
print\_eina\_container(\mbox{\hyperlink{struct__Eina__Iterator}{Eina\_Iterator}} *it)
\{
   \mbox{\hyperlink{group__Eina__Iterator__Group_gad9b7adc8db40a640d03e9bc4a5d52370}{eina\_iterator\_foreach}}(it, print\_one, NULL);
   printf(\textcolor{stringliteral}{"\(\backslash\)n"});
\}

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}}, \textcolor{keywordtype}{char} **argv \mbox{\hyperlink{group__Eina__Types__Group_ga82d751be730f849719ca292f9558be87}{EINA\_UNUSED}})
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *strings[] = \{
      \textcolor{stringliteral}{"unintersting string"}, \textcolor{stringliteral}{"husker"}, \textcolor{stringliteral}{"starbuck"}, \textcolor{stringliteral}{"husker"}
   \};
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *more\_strings[] = \{
      \textcolor{stringliteral}{"very unintersting string"},
      \textcolor{stringliteral}{"what do your hear?"},
      \textcolor{stringliteral}{"nothing but the rain"},
      \textcolor{stringliteral}{"then grab your gun and bring the cat in"}
   \};
   \mbox{\hyperlink{struct__Eina__Array}{Eina\_Array}} *array;
   \mbox{\hyperlink{struct__Eina__List}{Eina\_List}} *list = NULL;
   \mbox{\hyperlink{struct__Eina__Iterator}{Eina\_Iterator}} *it;
   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{short} \textcolor{keywordtype}{int} i;
   \textcolor{keywordtype}{char} *uninteresting;

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

   array = \mbox{\hyperlink{group__Eina__Array__Group_ga4a389204db37b44b31d29f581258ac7d}{eina\_array\_new}}(4);

   \textcolor{keywordflow}{for} (i = 0; i < 4; i++)
      \{
        \mbox{\hyperlink{group__Eina__Array__Group_gaf2f4a5907f1826354977adbd63e3379a}{eina\_array\_push}}(array, strings[i]);
        list = \mbox{\hyperlink{group__Eina__List__Group_ga92ec14d1a1040a361c4d8cd0ab7b0ecc}{eina\_list\_append}}(list, more\_strings[i]);
      \}

   it = \mbox{\hyperlink{group__Eina__Array__Group_ga3cc5cffcf52a2e8c60a651f8df66fbdf}{eina\_array\_iterator\_new}}(array);
   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eina__Iterator__Group_ga83346e93c32dbebc8fd66e4f278140c5}{eina\_iterator\_next}}(it, (\textcolor{keywordtype}{void} **)&uninteresting))
     \textcolor{keywordflow}{return} -1;
   print\_eina\_container(it);
   \mbox{\hyperlink{group__Eina__Array__Group_gacd0118606f9e5b42839b91ed0da8b168}{eina\_array\_free}}(\mbox{\hyperlink{group__Eina__Iterator__Group_ga5583ab703b156f74f0c2a74875c95cc2}{eina\_iterator\_container\_get}}(it));
   \mbox{\hyperlink{group__Eina__Iterator__Group_gaf9261991a4b05dc63e3401278a3281f8}{eina\_iterator\_free}}(it);

   it = \mbox{\hyperlink{group__Eina__List__Group_gabcfb6a861aa7c0db0ee36252ac2a254d}{eina\_list\_iterator\_new}}(list);
   \textcolor{keywordflow}{if} (!\mbox{\hyperlink{group__Eina__Iterator__Group_ga83346e93c32dbebc8fd66e4f278140c5}{eina\_iterator\_next}}(it, (\textcolor{keywordtype}{void} **)&uninteresting))
     \textcolor{keywordflow}{return} -1;
   print\_eina\_container(it);
   \mbox{\hyperlink{group__Eina__Iterator__Group_gaf9261991a4b05dc63e3401278a3281f8}{eina\_iterator\_free}}(it);

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

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

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