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

12
LINES

< > BotCompany Repo | #1031095 // getFromIterator

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

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

1  
static <A> A getFromIterator(Iterator<A> it, int idx) {
2  
  if (idx < 0) null;
3  
  while ping (true) {
4  
    if (!it.hasNext())
5  
      null;
6  
    else {
7  
      A a = it.next();
8  
      if (idx-- == 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: #1031095
Snippet name: getFromIterator
Eternal ID of this version: #1031095/1
Text MD5: c9a3c115d5ea1ecf3e8a80f2a143484a
Transpilation MD5: 463af550bc55981a259dc5bab5ee294b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-05-01 15:29:08
Source code size: 227 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 109 / 160
Referenced in: [show references]