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)

static abstract class SmartIterator {
  int n, i;
  SmartIterator bottom;
  
  O next();
}

static class SIList extends SmartIterator {
  List list;
  
  *(List *list) { n = list.size(); }
  
  O next() {
    if (i < n)
      return list.get(i++);
    return null;
  }
}

static class SIRepeat extends SmartIterator {
  SmartIterator base;
  
  *(SmartIterator *base) {}
  
  O next() {
    if (i == 0) return "";
    
  }
}

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