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).

1  
static <A> ItIt<A> cyclicListIterator(L<A> l) {
2  
  if (empty(l)) ret emptyItIt();
3  
  ret new ItIt<A> {
4  
    int i;
5  
    public bool hasNext() { true; }
6  
    public A next() {
7  
      A a = l.get(i);
8  
      if (++i >= l(l)) i = 0;
9  
      ret a;
10  
    }
11  
  };
12  
}

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: 277 / 366
Referenced in: [show references]