Skip to content

Commit 3de016f

Browse files
committed
WIP
1 parent 4b883f7 commit 3de016f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/tr.erl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
-export([contains_data/2,
3737
do/1,
3838
lookup/1,
39+
next/1, next/2, prev/1, prev/2,
3940
app_modules/1,
4041
mfarity/1,
4142
mfargs/2,
@@ -513,6 +514,24 @@ lookup(Index) when is_integer(Index) ->
513514
[T] = ets:lookup(tab(), Index),
514515
T.
515516

517+
next(#tr{index = Index, pid = Pid}) ->
518+
next(Pid, Index).
519+
520+
next(Pid, Index) ->
521+
case ets:next_lookup(tab(), Index) of
522+
{_NextIndex, [#tr{pid = Pid} = NextT]} -> NextT;
523+
{NextIndex, _} -> next(Pid, NextIndex)
524+
end.
525+
526+
prev(#tr{index = Index, pid = Pid}) ->
527+
prev(Pid, Index).
528+
529+
prev(Pid, Index) ->
530+
case ets:prev_lookup(tab(), Index) of
531+
{_PrevIndex, [#tr{pid = Pid} = NextT]} -> NextT;
532+
{PrevIndex, _} -> prev(Pid, PrevIndex)
533+
end.
534+
516535
%% @doc Returns all module names for an application.
517536
-spec app_modules(atom()) -> [module()].
518537
app_modules(AppName) ->

0 commit comments

Comments
 (0)