/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an AS IS BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
namespace ElmSharp
{
///
/// The Point is a struct that defines the 2D point as a pair of generic type.
///
/// preview
public struct Point : IEquatable
{
///
/// Location along the horizontal axis.
///
/// preview
public int X;
///
/// Location along the vertical axis.
///
/// preview
public int Y;
///
/// A human readable representation of .
///
/// The string is formatted as "{{X={0} Y={1}}}".
/// preview
public override string ToString()
{
return string.Format("{{X={0} Y={1}}}", X, Y);
}
///
/// Gets the hash code.
///
/// The hash code.
/// preview
public override int GetHashCode()
{
unchecked
{
return X.GetHashCode() ^ (Y.GetHashCode() * 397);
}
}
///
/// Indicates whether this instance and a specified object are equal.
///
/// The object to compare with the current instance.
///
/// true if the object and this instance are of the same type and represent the same value,
/// otherwise false.
///
/// preview
public override bool Equals(object obj)
{
if (!(obj is Point))
return false;
return Equals((Point)obj);
}
///
/// Indicates whether this instance and a object are equal.
///
/// The to compare with the current instance.
///
/// true if the object and this instance are the same type and represent the same value,
/// otherwise false.
///
/// preview
public bool Equals(Point other)
{
return X.Equals(other.X) && Y.Equals(other.Y);
}
///
/// Whether both s are equal.
///
/// A on the left hand side.
/// A on the right hand side.
/// True if both s have equal values.
/// preview
public static bool operator ==(Point p1, Point p2)
{
return p1.Equals(p2);
}
///
/// Whether both s are not equal.
///
/// A on the left hand side.
/// A on the right hand side.
/// True if both s do not have equal values.
/// preview
public static bool operator !=(Point p1, Point p2)
{
return !p1.Equals(p2);
}
}
}