]> O.S.I.I.S - jp/crow.git/commitdiff
NodeAddress hashcode
authorjpbruyere <jp.bruyere@hotmail.com>
Fri, 11 Nov 2016 10:15:57 +0000 (11:15 +0100)
committerjpbruyere <jp.bruyere@hotmail.com>
Fri, 11 Nov 2016 10:15:57 +0000 (11:15 +0100)
src/IML/NodeAddress.cs

index 4b9069755e050b161c6df1c9393961e04f11a5e8..95341ac74934da8a79a7c6b8c5eaea479bffc328 100644 (file)
@@ -30,6 +30,15 @@ namespace Crow.IML
                {
                        return obj is NodeAddress && this == obj as NodeAddress;
                }
+               public override int GetHashCode ()
+               {
+                       unchecked {
+                               int hash = 19;
+                               foreach (Node n in this)
+                                       hash = hash * 31 + (n == null ? 0 : n.GetHashCode ());  
+                               return hash;
+                       }
+               }
                public static bool operator == (NodeAddress x, NodeAddress y)
                {
                        return x.SequenceEqual (y);
@@ -38,5 +47,13 @@ namespace Crow.IML
                {
                        return !(x == y);
                }
+
+               public override string ToString ()
+               {
+                       string tmp = "";
+                       foreach (Node n in this)
+                               tmp += string.Format ("{0}[{1}];", n.CrowType.Name, n.Index);                   
+                       return tmp;
+               }
        }
 }