[Vala] Using Gee.ArrayList and Gee.Queue
- From: Osmo Antero <osmoma gmail com>
- To: vala-list gnome org
- Subject: [Vala] Using Gee.ArrayList and Gee.Queue
- Date: Fri, 11 May 2012 15:52:19 -0000
Hello,
I would like to use Vala for my next project, so I started to learn
some basic features.
Please see the example code below.
Question 1:
When compiling the program, it outputs the following warning:
$ valac --pkg gee-1.0 test.vala
/home/moma/V/list1.vala.c: In function ‘main_test’:
/home/moma/V/list1.vala.c:105:2: warning: passing argument 1 of
‘gee_abstract_collection_get_size’ from incompatible pointer type
[enabled by default]
/usr/include/gee-1.0/gee.h:755:6: note: expected ‘struct
GeeAbstractCollection *’ but argument is of type ‘struct GeeCollection
*’
It is caused by this statement:
stdout.printf("Size of list1:%u\n", list1.size);
But this statement (on list2.size) is perfectly OK.
stdout.printf("Size of list2:%u\n", list2.size);
So which of these two declarations is more correct?
public ArrayList<int> list1 = new Gee.ArrayList<int>();
or
public Gee.List<int> list2 = new Gee.ArrayList<int>();
Please see the example code below.
Compile it with:
$ valac --pkg gee-1.0 test.vala
And run:
./test
Should I use GLib.List<x> instead of Gee.ArrayList<x> consequently?
------------------------
Question 2:
Why does this gee.Queue declaration fails?
Gee.Queue<int> queue = new Gee.Queue<int>();
test.vala:198.28-198.47: error: `Gee.Queue' is not a class, struct, or
error code
Gee.Queue<int> queue = new Gee.Queue<int>();
^^^^^^^^^^^^^^^^^^^^
// --------------------------------------
// Example code (test.vala):
// --------------------------------------
using GLib, Gee;
public class Main {
public ArrayList<int> list1 = new Gee.ArrayList<int>();
public Gee.List<int> list2 = new Gee.ArrayList<int>();
public void test() {
for (var i = 0; i < 10; i++) {
list1.add(i);
}
stdout.printf("Size of list1:%u\n", list1.size);
for (var i = 0; i < 10; i++) {
list2.add(i);
}
stdout.printf("Size of list2:%u\n", list2.size);
}
public static int main (string[] args) {
var t = new Main();
t.test();
return 0;
}
}
// --------------------------------------
My system is:
$ cat /etc/issue
Ubuntu 12.04 LTS \n \l
Version of Vala is:
$ valac --version
Vala 0.17.0
Kindly
Osmo
http://www.futuredesktop.org
audio-recorder: https://launchpad.net/audio-recorder
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]