コンテンツ用の独自のクラスを持つ Gee.ArrayList を使用しています。ArrayList の「contains」メソッドを使用したいのですが、クラスで equals メソッドを設定する方法が本当にわからないため、ArrayList はそれを使用して、オブジェクトが ArrayList にあるかどうかを調べます。
例:
class Test : GLib.Object {
public int number;
public Test(int n) {
number = n;
}
public bool equals (Test other) {
if (number == other.number) return true;
return false;
}
}
次に、別のファイルで:
var t = new Gee.ArrayList<Test>();
var n1 = new Test(3);
var n2 = new Test(3);
t.add(n1);
t.contains(n2); // returns false, but I want it to return true
誰かそれを知っていますか?