Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

12
LINES

< > BotCompany Repo | #1030127 // cyclicListIterator

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2557L/16K).

static <A> ItIt<A> cyclicListIterator(L<A> l) {
  if (empty(l)) ret emptyItIt();
  ret new ItIt<A> {
    int i;
    public bool hasNext() { true; }
    public A next() {
      A a = l.get(i);
      if (++i >= l(l)) i = 0;
      ret a;
    }
  };
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1030127
Snippet name: cyclicListIterator
Eternal ID of this version: #1030127/1
Text MD5: cfb1a07f4c9be04de902898535428ab3
Transpilation MD5: f8a9e50abcf58376c3acff4f26c40d12
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-11-10 12:17:25
Source code size: 258 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 276 / 365
Referenced in: [show references]