

We start by including necessary headers, declaring variables, and initializing eina\+: 
\begin{DoxyCodeInclude}
\textcolor{preprocessor}{#include <stdio.h>}

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

\textcolor{keywordtype}{int}
main(\textcolor{keywordtype}{int} argc EINA\_UNUSED, \textcolor{keywordtype}{char} **argv EINA\_UNUSED)
\{
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *strings[] = \{
      \textcolor{stringliteral}{"even"}, \textcolor{stringliteral}{"odd"}, \textcolor{stringliteral}{"even"}, \textcolor{stringliteral}{"odd"}, \textcolor{stringliteral}{"even"}, \textcolor{stringliteral}{"odd"}, \textcolor{stringliteral}{"even"}, \textcolor{stringliteral}{"odd"}, \textcolor{stringliteral}{"even"}, \textcolor{stringliteral}{"odd"}
   \};
   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *more\_strings[] = \{
      \textcolor{stringliteral}{"0"}, \textcolor{stringliteral}{"1"}, \textcolor{stringliteral}{"2"}, \textcolor{stringliteral}{"3"}, \textcolor{stringliteral}{"4"}, \textcolor{stringliteral}{"5"}, \textcolor{stringliteral}{"6"}, \textcolor{stringliteral}{"7"}, \textcolor{stringliteral}{"8"}, \textcolor{stringliteral}{"9"}
   \};
   \hyperlink{struct__Eina__Array}{Eina\_Array} *array;
   \hyperlink{struct__Eina__List}{Eina\_List} *list = NULL;
   \hyperlink{struct__Eina__Accessor}{Eina\_Accessor} *acc;
   \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{short} \textcolor{keywordtype}{int} i;
   \textcolor{keywordtype}{void} *data;

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

\end{DoxyCodeInclude}


Next we populate our array and list\+: 
\begin{DoxyCodeInclude}

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

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

\end{DoxyCodeInclude}


Now that we have two containers populated we can actually start the example and create an accessor\+: 
\begin{DoxyCodeInclude}

   acc = \hyperlink{group__Eina__Array__Group_gab0886ce166e67d0e395e9e90b808d9b0}{eina\_array\_accessor\_new}(array);

\end{DoxyCodeInclude}


Once we have the accessor we can use it to access certain elements in the container\+: 
\begin{DoxyCodeInclude}
   \textcolor{keywordflow}{for}(i = 1; i < 10; i += 2)
     \{
        \hyperlink{group__Eina__Accessor__Group_ga08786da46a71eb2d1ad0ee07db8463cd}{eina\_accessor\_data\_get}(acc, i, &data);
        printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, (\textcolor{keyword}{const} \textcolor{keywordtype}{char} *)data);
     \}

\end{DoxyCodeInclude}
 \begin{DoxyNote}{Note}
Unlike iterators accessors allow us non-\/linear access, which allows us to print only the odd elements in the container.
\end{DoxyNote}
As with every other resource we allocate we need to free the accessor(and the array)\+: 
\begin{DoxyCodeInclude}
   \hyperlink{group__Eina__Accessor__Group_ga5ae101883822c1f01688fcef3a6585b8}{eina\_accessor\_free}(acc);
   \hyperlink{group__Eina__Array__Group_ga97995d81ca401d71a2913a52f8b40c41}{eina\_array\_free}(array);

\end{DoxyCodeInclude}


Now we create another accessor, this time for the list\+: 
\begin{DoxyCodeInclude}

   acc = \hyperlink{group__Eina__List__Group_ga6901b2ea29c9bc34a486dae00d3cf608}{eina\_list\_accessor\_new}(list);

\end{DoxyCodeInclude}


And now the interesting part, we use the same code we used above, to print parts of the array, to print parts of the list\+: 
\begin{DoxyCodeInclude}
   \textcolor{keywordflow}{for}(i = 1; i < 10; i += 2)
     \{
        \hyperlink{group__Eina__Accessor__Group_ga08786da46a71eb2d1ad0ee07db8463cd}{eina\_accessor\_data\_get}(acc, i, &data);
        printf(\textcolor{stringliteral}{"%s\(\backslash\)n"}, (\textcolor{keyword}{const} \textcolor{keywordtype}{char} *)data);
     \}

\end{DoxyCodeInclude}


And to free the list we use a gimmick, instead of freeing {\itshape list}, we ask the accessor for its container and we free that\+: 
\begin{DoxyCodeInclude}

   \hyperlink{group__Eina__List__Group_ga608bd2fbf06293a1b794648990703ab4}{eina\_list\_free}(\hyperlink{group__Eina__Accessor__Group_ga461c9ee7dec70fc5fa17acea0a59beb6}{eina\_accessor\_container\_get}(acc));

\end{DoxyCodeInclude}


Finally we shut eina down and leave\+: 
\begin{DoxyCodeInclude}
   \hyperlink{group__Eina__Accessor__Group_ga5ae101883822c1f01688fcef3a6585b8}{eina\_accessor\_free}(acc);

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

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

\end{DoxyCodeInclude}


The full source code can be found in the examples folder in the \hyperlink{eina_accessor_01_c}{eina\+\_\+accessor\+\_\+01.c} file. 