Gee Problem with TreeMap
- From: Daniel Espinosa <esodan gmail com>
- To: libgee-list gnome org
- Subject: Gee Problem with TreeMap
- Date: Mon, 11 Nov 2013 17:07:26 -0600
Please tell me what is wrong!!!!
I'm using a TreeMap as a container inside a class that need to be subclassed from other.
My problem is when I try to run my program fails to try get values and its key.
I'm using valac-0.20, even using 0.18.1.
using Gee;
class Base : Object
{
public string name { get; set; }
}
class Manager<V> : Base
{
private Gee.TreeMap<string,V> map = new Gee.TreeMap<string,V> ();
public new V get (string key)
{
return map.get (key);
}
public new void set (string key, V obj)
{
map.set (key, obj);
}
public Collection<V> values { owned get { return map.values; } }
public Collection<string> keys { owned get { return map.keys; } }
}
class Space : Object
{
public string name { get; set; }
public Space.named (string name) {
this.name = name; }
}
class User : Manager<Object> {}
class App
{
public static int main (string[] args)
{
var u = new User ();
var o1 = new Space.named ("Big");
var o2 = new Space.named ("Small");
u.set (
o1.name, o1);
u.set (
o2.name, o2);
foreach (Object o in u.values) {
stdout.printf (@"VALUE: $(((Space) o).name)\n");
}
foreach (string k in u.keys) {
stdout.printf (@"KEY: $(k) : VALUE: $(((Space) u.get (k)).name)\n");
}
return 0;
}
}
compiling using
valac-0.20 --pkg gee-0.8 container-manager.vala
and runnig gets corruption on keys and fails to get values:
$ ./container-manager
VALUE: Big
VALUE: Small
(process:29479): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `Space'
** (process:29479): CRITICAL **: string_to_string: assertion `self != NULL' failed
(process:29479): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
(process:29479): GLib-GObject-WARNING **: invalid uninstantiatable type `<invalid>' in cast to `Space'
** (process:29479): CRITICAL **: string_to_string: assertion `self != NULL' failed
(process:29479): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
(process:29479): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
(process:29479): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
KEY: Big : VALUE: KEY: Small : VALUE:
--
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates: LIBRE)
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]