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

27
LINES

< > BotCompany Repo | #1018353 // splittableSteppable_forEach

JavaX fragment (include)

1  
static <A> SplittableSteppable splittableSteppable_forEach(final Iterable<A> items, final VF1<A> f) {
2  
  ret new SplittableSteppable {
3  
    Iterator<A> it = iterator(items);
4  
    public bool step() { // return false if done
5  
      if (!it.hasNext()) false;
6  
      callF(f, it.next());
7  
      true;
8  
    }
9  
    
10  
    // invalidates original steppable
11  
    public L<Steppable> split(int n) {
12  
      final Lock lock = lock();
13  
      ret rep((Steppable) new Steppable {
14  
        public bool step() {
15  
          A a;
16  
          {
17  
            lock lock;
18  
            if (!it.hasNext()) false;
19  
            a = it.next();
20  
          }
21  
          callF(f, a);
22  
          true;
23  
        }
24  
      }, n);
25  
    }
26  
  };
27  
}

Author comment

Began life as a copy of #1018344

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018353
Snippet name: splittableSteppable_forEach
Eternal ID of this version: #1018353/3
Text MD5: a524a77e30042d019c06e88347ba3cfa
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-09-20 06:27:26
Source code size: 710 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 311 / 358
Version history: 2 change(s)
Referenced in: [show references]