gpt4 book ai didi

sorting - Erlang ETS 带有袋型元素排序

转载 作者:行者123 更新时间:2023-12-02 20:34:54 24 4
gpt4 key购买 nike

我有一些这样的代码:

Table = ets:new(table, [bag]),
true = ets:insert(Table, {bucket_1, some_value_1}),
true = ets:insert(Table, {bucket_1, some_value_2}),
true = ets:insert(Table, {bucket_1, some_value_3}),

LookupResult = ets:lookup(Table, bucket_1),
?_assertEqual(
[{bucket_1, some_value_1}, {bucket_1, some_value_2}, {bucket_1, some_value_3}],
LookupResult
).

ETS 是否保证桶内元素的排序?我是否应该期望 ETS 保存元素的顺序,因为元素已添加到表中?

最佳答案

specification of lookup/2说:

[...] the time order of object insertions is preserved; the first object inserted with the given key will be first in the resulting list, and so on.

关于sorting - Erlang ETS 带有袋型元素排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23714387/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com