blob: 059f4d7957b94a121a97f24b7399ebc6dbc3039f (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/*
* Eina.List examples.
*
* These examples demonstrate how to work with Eina.List data and methods.
* We create a simple list of names by appending strings to an empty list
* and then run various mutations and print each result.
*/
using System;
using System.Linq;
public class Example : Efl.Csharp.Application
{
static Eina.List<string> CreateList()
{
var list = new Eina.List<string>();
list.Append("Adama");
list.Append("Baltar");
list.Append("Roslin");
return list;
}
protected override void OnInitialize(string[] args)
{
var list = CreateList();
// Print our list with a simple foreach
Console.WriteLine("List size: {0}", list.Count());
Console.WriteLine("List content:");
foreach(string item in list)
Console.WriteLine(" {0}", item);
// Insert some more elements
list.Prepend("Cain");
// list.PrependRelative("Tigh", "Baltar"); // TODO: missing
Console.WriteLine("New list content:");
foreach(string item in list)
Console.WriteLine(" {0}", item);
// Promote an item to the top of the list
// TODO: implement ?
// list.PromoteList(list.NthList(1));
// list.Remove("Cain");
//
// Console.WriteLine("List content after promotion:");
// foreach(string item in list)
// Console.WriteLine(" {0}", item);
// We can sort the list with any callback
// list.Sort((string strA, string strB) => { return strA.Compare(strB); }); // TODO: FIXME custom sort
list.Sort();
Console.WriteLine("List content sorted:");
foreach(string item in list)
Console.WriteLine(" {0}", item);
// And foreach can be in reverse too
Console.WriteLine("List content reverse sorted:");
foreach(string item in list.Reverse())
Console.WriteLine(" {0}", item);
list.Dispose();
Efl.App.AppMain.Quit(0);
}
public static void Main()
{
var example = new Example();
example.Launch();
}
}
|