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

40
LINES

< > BotCompany Repo | #1029019 // mapI_nonNulls_if1

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

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

1  
static <A, B> ItIt<B> mapI_nonNulls_if1(Iterable<A> i, IF1<A, B> f) {
2  
  ret mapI_nonNulls_if1(f, i);
3  
}
4  
5  
static <A, B> ItIt<B> mapI_nonNulls_if1(IF1<A, B> f, Iterable<A> i) {
6  
  ret i == null ? null : mapI_nonNulls_if1(f, i.iterator());
7  
}
8  
9  
static <A, B> ItIt<B> mapI_nonNulls_if1(IF1<A, B> f, Iterator<A> i) {
10  
  if (i == null) null;
11  
  class I extends ItIt<B> {
12  
    B a;
13  
    bool done;
14  
    
15  
    public bool hasNext() {
16  
      getNext();
17  
      ret !done;
18  
    }
19  
    
20  
    public B next() {
21  
      getNext();
22  
      if (done) fail();
23  
      B _a = a;
24  
      a = null;
25  
      ret _a;
26  
    }
27  
    
28  
    void getNext() {
29  
      if (done || a != null) ret;
30  
      while ping (true) {
31  
        if (!i.hasNext())
32  
          ret with done = true;
33  
        B _a = f.get(i.next());
34  
        if (_a != null)
35  
          ret with a = _a;
36  
      }
37  
    }
38  
  };
39  
  ret new I;
40  
}

Author comment

Began life as a copy of #1004292

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1029019
Snippet name: mapI_nonNulls_if1
Eternal ID of this version: #1029019/6
Text MD5: 6351c36f3bd1d763fa26ab25b47dfebb
Transpilation MD5: 69d3df6c45d5f1f356aac2bf6bce7305
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-07-16 23:12:49
Source code size: 875 bytes / 40 lines
Pitched / IR pitched: No / No
Views / Downloads: 152 / 236
Version history: 5 change(s)
Referenced in: [show references]