ets:select_reverse/3
根据匹配规范匹配表里的对象数据
用法:
1 | select_reverse( Tab , MatchSpec , Limit ) -> {[ Match ], Continuation } | `$end_of_table` |
跟 ets:select/3 一样,都是根据匹配规范匹配表里的对象数据,不过如果是 ordered_set 类型的 ETS 表的话,遍历会在 Erlang 数据的最后一笔对象数据开始,并会把它移到第一个位置。其他类型的表返回的值跟 ets:select/3 一样。
1 2 3 4 | T = ets:new (x, [ordered_set]), [ ets:insert (T, {N}) || N <- lists:seq (1, 10) ], { Match , _ Continuation } = ets:select_reverse (T, [{ '_' , [], [ '$_' ]}], 4), Match . |
该函数并不是倒转调用函数 ets:select/3 所返回的结果列表,因为结果列表并不仅仅是倒转,同时也包含着表里最后 Limit 条的匹配数据。