summaryrefslogtreecommitdiffstats
path: root/src/Ref.vala
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-10-04 23:57:17 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-10-04 23:57:17 +0200
commit3639520b85a4c05334b7e8920d42a33b0831c3f0 (patch)
tree910234e26918a492fb28e18cd37a7849a14621d7 /src/Ref.vala
parent7e78f35505151c03688e988d2108604b208329db (diff)
downloadeva-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.vala13
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);