79 lines
1.8 KiB
C#
79 lines
1.8 KiB
C#
|
|
/*
|
|
* Eina Iterator examples.
|
|
*
|
|
* These examples demonstrate how to work with Eina_iterator methods.
|
|
* Both an Eina_list and an Eina_array are created and an iterator obtained
|
|
* for both. You can see how we can use iterators irrespective of the source
|
|
* and also that there are different ways to work with iterating content.
|
|
*/
|
|
|
|
using System;
|
|
|
|
public class Example
|
|
{
|
|
static void PrintIterator(Eina.Iterator<string> it)
|
|
{
|
|
Console.WriteLine("--iterator start--");
|
|
foreach(string s in it)
|
|
Console.WriteLine(s);
|
|
Console.WriteLine("-- iterator end --");
|
|
}
|
|
|
|
static Eina.Array<string> CreateArray()
|
|
{
|
|
string[] strings =
|
|
{
|
|
"name strings",
|
|
"husker",
|
|
"starbuck",
|
|
"boomer"
|
|
};
|
|
|
|
var array = new Eina.Array<string>(4u);
|
|
|
|
foreach (string s in strings)
|
|
array.Push(s);
|
|
|
|
return array;
|
|
}
|
|
|
|
static Eina.List<string> CreateList()
|
|
{
|
|
string[] more_strings = {
|
|
"sentence strings",
|
|
"what do your hear?",
|
|
"nothing but the rain",
|
|
"then grab your gun and bring the cat in"
|
|
};
|
|
|
|
var list = new Eina.List<string>();
|
|
|
|
foreach (string s in more_strings)
|
|
list.Append(s);
|
|
|
|
return list;
|
|
}
|
|
|
|
public static void Main()
|
|
{
|
|
Efl.All.Init();
|
|
|
|
// create an Eina.Array and iterate through it's contents
|
|
var array = CreateArray();
|
|
var it = array.GetIterator();
|
|
PrintIterator(it);
|
|
it.Dispose();
|
|
array.Dispose();
|
|
|
|
// perform the same iteration with an Eina.List
|
|
var list = CreateList();
|
|
it = list.GetIterator();
|
|
PrintIterator(it);
|
|
it.Dispose();
|
|
list.Dispose();
|
|
|
|
Efl.All.Shutdown();
|
|
}
|
|
}
|