<commit_before>﻿using System;
using System.Diagnostics.CodeAnalysis;


namespace ManagedX.Input
{

	/// <summary>A mouse state.</summary>
	public struct MouseState : IEquatable<MouseState>
	{

		private int x;
		private int y;
		private int wheel;
		private bool[] buttons;


		/// <summary>Initializes a new <see cref="MouseState"/> structure.</summary>
		/// <param name="x">The horizontal position of the mouse cursor.</param>
		/// <param name="y">The vertical position of the mouse cursor.</param>
		/// <param name="wheel">The mouse wheel value.</param>
		/// <param name="buttons">An array of 5 boolean values indicating whether a button is pressed.</param>
		/// <exception cref="ArgumentNullException"/>
		/// <exception cref="ArgumentException"/>
		internal MouseState( int x, int y, int wheel, bool[] buttons )
		{
#if DEBUG
			if( buttons == null )
				throw new ArgumentNullException( "buttons" );
			
			if( buttons.Length != 5 )
				throw new ArgumentException( "Mouse buttons state array must be 5 bool-long.", "buttons" );
#endif	
			this.x = x;
			this.y = y;
			this.wheel = wheel;
			this.buttons = buttons;
		}


		/// <summary>Gets the horizontal mouse position, in pixels.</summary>
		[SuppressMessage( "Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "X" )]
		public int X { get { return x; } }

		/// <summary>Gets the vertical mouse position, in pixels.</summary>
		[SuppressMessage( "Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Y" )]
		public int Y { get { return y; } }


		/// <summary>Gets the wheel value.</summary>
		public int Wheel { get { return wheel; } }


		/// <summary>Gets a value indicating whether a button is down.</summary>
		/// <param name="button">A mouse button.</param>
		/// <returns>Returns true if the button is down, otherwise returns false.</returns>
		public bool this[ MouseButton button ] { get { return buttons[ (int)button ]; } }


		/// <summary>Returns a hash code for this <see cref="MouseState"/> structure.</summary>
		/// <returns>Returns a hash code for this <see cref="MouseState"/> structure.</returns>
		public override int GetHashCode()
		{
			return x ^ y ^ wheel ^ buttons.GetHashCode();
		}


		/// <summary>Returns a value indicating whether this <see cref="MouseState"/> structure equals another structure of the same type.</summary>
		/// <param name="other">A <see cref="MouseState"/> structure.</param>
		/// <returns>Returns true if this structure equals the <paramref name="other"/> structure, otherwise returns false.</returns>
		public bool Equals( MouseState other )
		{
			return ( x == other.x ) && ( y == other.y ) && ( wheel == other.wheel ) && ( buttons == other.buttons );
		}


		/// <summary>Returns a value indicating whether this <see cref="MouseState"/> structure is equivalent to an object.</summary>
		/// <param name="obj">An object.</param>
		/// <returns>Returns true if the specified object is a <see cref="MouseState"/> structure which equals this structure, otherwise returns false.</returns>
		public override bool Equals( object obj )
		{
			return ( obj is MouseState ) && this.Equals( (MouseState)obj );
		}



		/// <summary>The empty <see cref="MouseState"/> structure.</summary>
		public static readonly MouseState Empty = new MouseState( 0, 0, 0, new bool[ 5 ] );


		#region Operators


		/// <summary>Equality comparer.</summary>
		/// <param name="mouseState">A <see cref="MouseState"/> structure.</param>
		/// <param name="other">A <see cref="MouseState"/> structure.</param>
		/// <returns>Returns true if the structures are equal, otherwise returns false.</returns>
		public static bool operator ==( MouseState mouseState, MouseState other )
		{
			return mouseState.Equals( other );
		}


		/// <summary>Inequality comparer.</summary>
		/// <param name="mouseState">A <see cref="MouseState"/> structure.</param>
		/// <param name="other">A <see cref="MouseState"/> structure.</param>
		/// <returns>Returns true if the structures are not equal, otherwise returns false.</returns>
		public static bool operator !=( MouseState mouseState, MouseState other )
		{
			return !mouseState.Equals( other );
		}
<commit_msg>Improved design.<commit_after>﻿using System;


namespace ManagedX.Input
{

	/// <summary>A mouse state.</summary>
	public struct MouseState : IEquatable<MouseState>
	{

		private const int MaxSupportedButtonCount = 5;


		private Point position;
		private int wheel;
		private bool[] buttons;


		#region Constructors

		/// <summary>Initializes a new <see cref="MouseState"/> structure.</summary>
		/// <param name="position">The mouse cursor position.</param>
		/// <param name="wheel">The mouse wheel value.</param>
		/// <param name="buttons">An array of 5 boolean values indicating whether a button is pressed.</param>
		internal MouseState( ref Point position, int wheel, bool[] buttons )
		{
			this.position = position;
			this.wheel = wheel;
			this.buttons = buttons;
		}

		private MouseState( int buttonCount )
		{
			this.position = Point.Zero;
			this.wheel = 0;
			this.buttons = new bool[ buttonCount ];
		}

		#endregion
		

		/// <summary>Gets the mouse cursor position.</summary>
		public Point Position { get { return this.position; } }


		/// <summary>Gets the wheel value.</summary>
		public int Wheel { get { return wheel; } }


		/// <summary>Gets a value indicating whether a button is down.</summary>
		/// <param name="button">A mouse button.</param>
		/// <returns>Returns true if the button is down, otherwise returns false.</returns>
		public bool this[ MouseButton button ] { get { return buttons[ (int)button ]; } }


		/// <summary>Returns a value indicating whether a button is down.</summary>
		/// <param name="button">A mouse button.</param>
		/// <returns>Returns true if the button is down, otherwise returns false.</returns>
		public bool IsDown( MouseButton button )
		{
			return buttons[ (int)button ];
		}


		/// <summary>Returns a hash code for this <see cref="MouseState"/> structure.</summary>
		/// <returns>Returns a hash code for this <see cref="MouseState"/> structure.</returns>
		public override int GetHashCode()
		{
			return position.GetHashCode() ^ wheel ^ ( ( buttons == null ) ? 0 : buttons.GetHashCode() );
		}


		/// <summary>Returns a value indicating whether this <see cref="MouseState"/> structure equals another structure of the same type.</summary>
		/// <param name="other">A <see cref="MouseState"/> structure.</param>
		/// <returns>Returns true if this structure equals the <paramref name="other"/> structure, otherwise returns false.</returns>
		public bool Equals( MouseState other )
		{
			return position.Equals( other.position ) && ( wheel == other.wheel ) && ( buttons == other.buttons );
		}


		/// <summary>Returns a value indicating whether this <see cref="MouseState"/> structure is equivalent to an object.</summary>
		/// <param name="obj">An object.</param>
		/// <returns>Returns true if the specified object is a <see cref="MouseState"/> structure which equals this structure, otherwise returns false.</returns>
		public override bool Equals( object obj )
		{
			return ( obj is MouseState ) && this.Equals( (MouseState)obj );
		}



		/// <summary>The empty <see cref="MouseState"/> structure.</summary>
		public static readonly MouseState Empty = new MouseState( MaxSupportedButtonCount );


		#region Operators


		/// <summary>Equality comparer.</summary>
		/// <param name="mouseState">A <see cref="MouseState"/> structure.</param>
		/// <param name="other">A <see cref="MouseState"/> structure.</param>
		/// <returns>Returns true if the structures are equal, otherwise returns false.</returns>
		public static bool operator ==( MouseState mouseState, MouseState other )
		{
			return mouseState.Equals( other );
		}


		/// <summary>Inequality comparer.</summary>
		/// <param name="mouseState">A <see cref="MouseState"/> structure.</param>
		/// <param name="other">A <see cref="MouseState"/> structure.</param>
		/// <returns>Returns true if the structures are not equal, otherwise returns false.</returns>
		public static bool operator !=( MouseState mouseState, MouseState other )
		{
			return !mouseState.Equals( other );
		}

{'fraction_non_alphanumeric': 0.14188449848024315, 'fraction_numerical': 0.002310030395136778, 'mean_word_length': 3.6738636363636363, 'pattern_counts': {'":': 0, '<': 151, '<?xml version=': 0, '>': 151, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2815939', 'n_tokens_mistral': 2479, 'n_tokens_neox': 2242, 'n_words': 772}