🧰 UDK.Array
This content is not available in your language yet.
UniX-SDK.Array
Section titled “UniX-SDK.Array”UDK.Array.GetValueByEnum
Section titled “UDK.Array.GetValueByEnum”传参/返回值 | 类型 | 说明 |
---|---|---|
@param table | table | 枚举数组 |
@param target | string/number | 目标Key值或Value值 |
@return value | string/number | 返回的Key值或Value值 |
-- 示例代码local CoolStuff = {Foo="Foo", Bar="Bar", Baz="Baz"}
print(UDK.Array.GetValueByEnum(CoolStuff, "Bar")) -- Output: Bar
UDK.Array.AddValueByEnum
Section titled “UDK.Array.AddValueByEnum”传参/返回值 | 类型 | 说明 |
---|---|---|
@param table | table | 枚举数组 |
@param key | string | 要设置的Key值 |
@param value | string/number | 要设置的Value值 |
-- 示例代码local CoolStuff = {Foo="Foo", Bar="Bar", Baz="Baz"}
UDK.Array.AddValueByEnum(CoolStuff, "SUS", 123)
print(UDK.Array.GetValueByEnum(CoolStuff, "SUS")) -- Output: 123
UDK.Array.RemoveValueByEnum
Section titled “UDK.Array.RemoveValueByEnum”传参/返回值 | 类型 | 说明 |
---|---|---|
@param table | table | 枚举数组 |
@param taget | string/number | 目标的Key值或Value值 |
-- 示例代码local CoolStuff = {Foo="Foo", Bar="Bar", Baz="Baz"}
UDK.Array.RemoveValueByEnum(CoolStuff, "Foo")
print(UDK.Array.GetValueByEnum(CoolStuff, "Foo")) -- Output: nil
UDK.Array.ReplaceValueByEnum
Section titled “UDK.Array.ReplaceValueByEnum”传参/返回值 | 类型 | 说明 |
---|---|---|
@param table | table | 枚举数组 |
@param target | string/number | 目标Key值或Value值 |
@param newValue | string/number | 新的替换Value值 |
-- 示例代码local CoolStuff = {Foo="Foo", Bar="Bar", Baz="Baz"}
UDK.Array.ReplaceValueByEnum(CoolStuff, "Foo", 123)
print(UDK.Array.GetValueByEnum(CoolStuff, "Foo")) -- Output: 123
UDK.Array.ForKeyToValueRegX
Section titled “UDK.Array.ForKeyToValueRegX”传参/返回值 | 类型 | 说明 |
---|---|---|
@param table | table | 枚举数组 |
@param regX | string | 正则表达式 |
@return table | table | 返回的枚举数组 |
-- 示例代码local CoolStuff = {Foo="Foo", Bar="Bar", Baz="Baz"}
-- 遍历所有以 Ba 开头的键,并返回值(使用"."匹配任何字符)local myTable = UDK.Array.ForKeyToValueByEnum(CoolStuff, "Ba")
for key, value in pairs(myTable) do print( value) -- Output: Bar, Bazend
UDK.Array.SortArrayByKey
Section titled “UDK.Array.SortArrayByKey”传参/返回值 | 类型 | 说明 |
---|---|---|
@param table | table | 要排序的数组 |
@return table | sorted_table | 返回排序后的数组 |
-- 示例代码local CoolStuff = {Foo="Foo", Bar="Bar", Baz="Baz"}local sorted_table = UDK.Array.SortArrayByKey(CoolStuff)
for key, value in pairs(sorted_table) do print( value) -- Output: Bar, Baz, Fooend