The following classes can have these overrides implemented:
Vector3
TaxiNode
A correct implementation would look like this:
public override int GetHashCode() { return (Position.X.GetHashCode() * 397 ^ Position.Y.GetHashCode()) * 397 ^ Position.Z.GetHashCode(); } public override bool Equals(object obj) { Node rhs = obj as Node; if (rhs == null) return false; return Position.X == rhs.Position.X && Position.Y == rhs.Position.Y && Position.Z == rhs.Position.Z; }
This will enable the usage of the class in Dictionary<> and HashSet<>.
These collections provide higher performance and uniqueness of each inserted element.
List<> collection's behavior will stay the same.
Recommended Comments
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now