From 3639520b85a4c05334b7e8920d42a33b0831c3f0 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 4 Oct 2010 23:57:17 +0200 Subject: Added Comparable interface to Ref (and fixed some warnings) --- src/Ref.vala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Ref.vala') diff --git a/src/Ref.vala b/src/Ref.vala index b1fd4e9..17ae2cf 100644 --- a/src/Ref.vala +++ b/src/Ref.vala @@ -1,5 +1,5 @@ namespace Eva { - public class Ref : Object, Term { + public class Ref : Object, Term, Gee.Comparable { public string node {get; construct;} public int len {get; construct;} public uint[] n {get; private set;} @@ -22,6 +22,17 @@ namespace Eva { return "#Ref"; } + public int compare_to(Ref o) { + for(int i = 0; i < len; ++i) { + if(n[i] < o.n[i]) + return -1; + if(n[i] > o.n[i]) + return 1; + } + + return 0; + } + protected bool do_match(Term o, Gee.Map vars, Gee.Map aliases) { if(o is Var) { return o.do_match(this, vars, aliases); -- cgit v1.2.3