[LUA]获取 table 中出现次数最多的整数
[LUA]Getting most recurring integer in a table
我需要在 lua table 中获得最经常出现的 vIndex
结构如下:
{{id=0, vIndex = 0},{id=34, vIndex = 1},...}
最好的方法是什么?
遍历 table 中的每个元素并跟踪另一个 table 中出现的次数,其中 vIndex
的每个值都是一个键。然后遍历第二个 table 以找到具有最大值的元素。这将是您最常使用的 vIndex
.
我需要在 lua table 中获得最经常出现的 vIndex
结构如下:
{{id=0, vIndex = 0},{id=34, vIndex = 1},...}
最好的方法是什么?
遍历 table 中的每个元素并跟踪另一个 table 中出现的次数,其中 vIndex
的每个值都是一个键。然后遍历第二个 table 以找到具有最大值的元素。这将是您最常使用的 vIndex
.