diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-10-04 23:57:17 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2010-10-04 23:57:17 +0200 |
commit | 3639520b85a4c05334b7e8920d42a33b0831c3f0 (patch) | |
tree | 910234e26918a492fb28e18cd37a7849a14621d7 /src/Ref.vala | |
parent | 7e78f35505151c03688e988d2108604b208329db (diff) | |
download | eva-3639520b85a4c05334b7e8920d42a33b0831c3f0.tar eva-3639520b85a4c05334b7e8920d42a33b0831c3f0.zip |
Added Comparable interface to Ref
(and fixed some warnings)
Diffstat (limited to 'src/Ref.vala')
-rw-r--r-- | src/Ref.vala | 13 |
1 files changed, 12 insertions, 1 deletions
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<Ref> { 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<string, Term> vars, Gee.Map<string, string> aliases) { if(o is Var) { return o.do_match(this, vars, aliases); |