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

29
LINES

< > BotCompany Repo | #1000771 // Smart iterator (developing)

JavaX fragment (include)

1  
static abstract class SmartIterator {
2  
  int n, i;
3  
  SmartIterator bottom;
4  
  
5  
  O next();
6  
}
7  
8  
static class SIList extends SmartIterator {
9  
  List list;
10  
  
11  
  *(List *list) { n = list.size(); }
12  
  
13  
  O next() {
14  
    if (i < n)
15  
      return list.get(i++);
16  
    return null;
17  
  }
18  
}
19  
20  
static class SIRepeat extends SmartIterator {
21  
  SmartIterator base;
22  
  
23  
  *(SmartIterator *base) {}
24  
  
25  
  O next() {
26  
    if (i == 0) return "";
27  
    
28  
  }
29  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1000771
Snippet name: Smart iterator (developing)
Eternal ID of this version: #1000771/1
Text MD5: 02e4255f302682e3b878964ad6c4dc74
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-26 21:00:09
Source code size: 452 bytes / 29 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 666 / 612
Referenced in: [show references]