Browse Source

added compare

Nicolas Cannasse 17 years ago
parent
commit
2e1741e35a
2 changed files with 8 additions and 0 deletions
  1. 1 0
      doc/CHANGES.txt
  2. 7 0
      std/Reflect.hx

+ 1 - 0
doc/CHANGES.txt

@@ -8,6 +8,7 @@
 	added js.Selection
 	added js.Selection
 	simplified js.Dom (more events)
 	simplified js.Dom (more events)
 	added haxe.xml.Fast.innerHTML
 	added haxe.xml.Fast.innerHTML
+	added Reflect.compare
 
 
 2008-01-13: 1.17
 2008-01-13: 1.17
 	fixed Int32.compare, added Int32.read and Int32.write
 	fixed Int32.compare, added Int32.read and Int32.write

+ 7 - 0
std/Reflect.hx

@@ -213,6 +213,13 @@ class Reflect {
 			;
 			;
 	}
 	}
 
 
+	/**
+		Generic comparison function, does not work for methods, see [compareMethods]
+	**/
+	public static function compare<T>( a : T, b : T ) : Int {
+		return ( a == b ) ? 0 : (((cast a) > (cast b)) ? 1 : -1);
+	}
+
 	/**
 	/**
 		Compare two methods closures. Returns true if it's the same method of the same instance.
 		Compare two methods closures. Returns true if it's the same method of the same instance.
 		Does not work on Neko platform.
 		Does not work on Neko platform.