From 42d3fbc69fced1c1efd6901d93570e32b6b1a892 Mon Sep 17 00:00:00 2001 From: LiRuoChen <571244399@qq.com> Date: Mon, 30 Oct 2023 09:40:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=9E=9A=E4=B8=BE?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=89=A9=E5=B1=95=E4=B8=AD=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E7=9A=84=E7=BC=BA=E9=99=B7=EF=BC=9B=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BA=86=E5=9C=A8=E5=88=97=E8=A1=A8=E4=B8=AD=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E9=A1=B9=E7=9B=AE=E7=9A=84=E6=89=A9=E5=B1=95?= =?UTF-8?q?=EF=BC=9B=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=95=B0=E5=80=BC?= =?UTF-8?q?=E8=BD=AC=E4=B8=AD=E6=96=87=E6=A0=BC=E5=BC=8F=E7=9A=84=E7=B9=81?= =?UTF-8?q?=E4=BD=93=E5=AD=97=E5=BA=93=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/MicroLibrary/MacroEnum.cs | 20 ++++++++++---------- Runtime/MicroLibrary/MacroList.cs | 18 ++++++++++++++++++ Runtime/MicroLibrary/MacroString.cs | 6 +++++- 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/Runtime/MicroLibrary/MacroEnum.cs b/Runtime/MicroLibrary/MacroEnum.cs index 9a843e5..258b831 100644 --- a/Runtime/MicroLibrary/MacroEnum.cs +++ b/Runtime/MicroLibrary/MacroEnum.cs @@ -188,7 +188,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater(this Enum target) { - return target.EnumToInt32() > 0; + return target.EnumToInt32() != 0; } /// @@ -198,7 +198,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater(this Enum target, Enum value) { - return (target.EnumToInt32() & value.EnumToInt32()) > 0; + return (target.EnumToInt32() & value.EnumToInt32()) != 0; } /// @@ -208,7 +208,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater1(this Enum target) { - return (target.EnumToInt32() & 01) > 0; + return (target.EnumToInt32() & 01) != 0; } /// @@ -218,7 +218,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater2(this Enum target) { - return (target.EnumToInt32() & 02) > 0; + return (target.EnumToInt32() & 02) != 0; } /// @@ -228,7 +228,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater3(this Enum target) { - return (target.EnumToInt32() & 04) > 0; + return (target.EnumToInt32() & 04) != 0; } /// @@ -238,7 +238,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater4(this Enum target) { - return (target.EnumToInt32() & 010) > 0; + return (target.EnumToInt32() & 010) != 0; } /// @@ -248,7 +248,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater5(this Enum target) { - return (target.EnumToInt32() & 020) > 0; + return (target.EnumToInt32() & 020) != 0; } /// @@ -258,7 +258,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater6(this Enum target) { - return (target.EnumToInt32() & 030) > 0; + return (target.EnumToInt32() & 030) != 0; } /// @@ -268,7 +268,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater7(this Enum target) { - return (target.EnumToInt32() & 040) > 0; + return (target.EnumToInt32() & 040) != 0; } /// @@ -278,7 +278,7 @@ namespace XericLibrary.Runtime.MacroLibrary [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool EnumGreater8(this Enum target) { - return (target.EnumToInt32() & 0100) > 0; + return (target.EnumToInt32() & 0100) != 0; } /// diff --git a/Runtime/MicroLibrary/MacroList.cs b/Runtime/MicroLibrary/MacroList.cs index 1e79ab2..179dadf 100644 --- a/Runtime/MicroLibrary/MacroList.cs +++ b/Runtime/MicroLibrary/MacroList.cs @@ -85,5 +85,23 @@ namespace XericLibrary.Runtime.MacroLibrary } #endregion + + #region 应用算法 + + /// + /// 获取列表中随机顺序的对象 + /// + /// + /// + /// 需要采样的数量 + /// + public static IEnumerable GetRandom(this List list, int count = -1) + { + var index = FisherYatesShuffle(list.Count, count <= 0 ? list.Count : count); + for(int i = 0; i < index.Count; i++) + yield return list[index[i]]; + } + + #endregion } } \ No newline at end of file diff --git a/Runtime/MicroLibrary/MacroString.cs b/Runtime/MicroLibrary/MacroString.cs index eb7fd36..650640c 100644 --- a/Runtime/MicroLibrary/MacroString.cs +++ b/Runtime/MicroLibrary/MacroString.cs @@ -62,6 +62,11 @@ namespace XericLibrary.Runtime.MacroLibrary private static readonly string[] chineseDigit = new string[] { "","十","百","千","万","十","百","千","亿","十","百","千","亿"}; + private static readonly string[] chineseNumber_ComplexFont = new string[] + {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"}; + private static readonly string[] chineseDigit_ComplexFont = new string[] + { "","拾","佰","仟","万","拾","佰","仟","亿","拾","佰","仟","亿"}; + /// /// 将一个数值转为中文小写格式; /// @@ -98,7 +103,6 @@ namespace XericLibrary.Runtime.MacroLibrary /// 将一个数值转为中文小写格式,并确保读写格式满足日常使用; /// 比如 510会读成五百一十,9009会读成九千零九, /// 最大支持到九千亿,理论上并不是它的极限,只要继续套格式即可。 - /// 不过缺点是在读10,11时,会读成一十,一十一,需要额外处理一下以符合阅读习惯 /// /// ///