From 0cba1203c9bc71ff038658aa2e0114b7b6718ae3 Mon Sep 17 00:00:00 2001 From: Nathan Curtis Date: Wed, 9 May 2007 00:02:36 +0000 Subject: [PATCH] implement equalable git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4700 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/as/com/threerings/util/Line.as | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/as/com/threerings/util/Line.as b/src/as/com/threerings/util/Line.as index 1e3cc367e..40850b927 100644 --- a/src/as/com/threerings/util/Line.as +++ b/src/as/com/threerings/util/Line.as @@ -27,7 +27,7 @@ import flash.geom.Matrix; /** * Merely a typed container for two Points. */ -public class Line +public class Line implements Equalable { public static const INTERSECTION_NORTH :int = 1; public static const INTERSECTION_SOUTH :int = 2; @@ -85,5 +85,30 @@ public class Line return DOES_NOT_INTERSECT; } } + + // from interface Equalable + public function equals (o :Object) :Boolean + { + var other :Line = o as Line; + if (other == null) { + return false; + } + + if (start == null || other.start == null) { + if (start != other.start) { + // not both null + return false; + } + } + if (stop == null || other.stop == null) { + if (stop != other.stop) { + // not both null + return false; + } + } + + return (start == null || start.equals(other.start)) && + (stop == null || stop.equals(other.stop)); + } } }