<commit_before>﻿using System;

namespace Yetibyte.Utilities {
	
	public static class MathUtil {
		
        // Constants

        /// <summary>
        /// A very small floating point number. Can be used to check whether a float or a double value is 0. 
        /// Any number smaller than EPSILON can be assumed to be equal to 0.
        /// </summary>
		public const float EPSILON = 0.000005f;
		    
        // Fields
           
		private static Random _random = new Random();

        // Properties

        /// <summary>
        /// Provides a static instance of the Random class for quick access to random number generation. The seed for this Random
        /// instance never changes.
        /// </summary>
        public static Random Random { get { return _random; } }

        // Methods

        /// <summary>
        /// Clamps the given value between the minimum and maximum value. I. e. the returned value will never be smaller than min
        /// or greater than max.
        /// </summary>
        /// <typeparam name="T">The type of the value to clamp. Must implement the IComparable interface.</typeparam>
        /// <param name="min">The minimum value.</param>
        /// <param name="max">The maximum value.</param>
        /// <param name="value">The value to clamp.</param>
        /// <returns>The minimum value if the value is smaller than min.
        /// The maximum value if the value is greater than max.
        /// Otherwise the value will be returned as is.</returns>
        public static T Clamp<T> (T min, T max, T value) where T : IComparable {
			
			if(value.CompareTo(min) < 0)
				return min;
			
			if(value.CompareTo(max) > 0)
				return max;
			
			return value;
						
		}
		<commit_msg>the static instance of Random is now read-only<commit_after>﻿using System;

namespace Yetibyte.Utilities {
	
	public static class MathUtil {
		
        // Constants

        /// <summary>
        /// A very small floating point number. Can be used to check whether a float or a double value is 0. 
        /// Any number smaller than EPSILON can be assumed to be equal to 0.
        /// </summary>
		public const float EPSILON = 0.000005f;
		    
        // Fields
           
		private static readonly Random _random = new Random();

        // Properties

        /// <summary>
        /// Provides a static instance of the Random class for quick access to random number generation. The seed for this Random
        /// instance never changes.
        /// </summary>
        public static Random Random => _random;

        // Methods

        /// <summary>
        /// Clamps the given value between the minimum and maximum value. I. e. the returned value will never be smaller than min
        /// or greater than max.
        /// </summary>
        /// <typeparam name="T">The type of the value to clamp. Must implement the IComparable interface.</typeparam>
        /// <param name="min">The minimum value.</param>
        /// <param name="max">The maximum value.</param>
        /// <param name="value">The value to clamp.</param>
        /// <returns>The minimum value if the value is smaller than min.
        /// The maximum value if the value is greater than max.
        /// Otherwise the value will be returned as is.</returns>
        public static T Clamp<T> (T min, T max, T value) where T : IComparable {
			
			if(value.CompareTo(min) < 0)
				return min;
			
			if(value.CompareTo(max) > 0)
				return max;
			
			return value;
						
		}
		
{'fraction_non_alphanumeric': 0.10160274756725815, 'fraction_numerical': 0.006296508299942759, 'mean_word_length': 1.900414937759336, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 40, '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': '6789879', 'n_tokens_mistral': 1002, 'n_tokens_neox': 886, 'n_words': 394}