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

21
LINES

< > BotCompany Repo | #1036114 // CloseableMapI - mapping iterator with closing

JavaX fragment (include)

1  
sclass CloseableMapI<A, B> extends CloseableItIt<B> {
2  
  IF1<A, B> f;
3  
  Iterator<A> it;
4  
  
5  
  *(IF1<A, B> *f, Iterator<A> *it) {}
6  
  
7  
  public bool hasNext() {
8  
    ret it.hasNext();
9  
  }
10  
  
11  
  public B next() {
12  
    ret f.get(it.next());
13  
  }
14  
  
15  
  close {
16  
    if (it cast AutoCloseable) {
17  
      it.close();
18  
      it = null;
19  
    }
20  
  }
21  
}

Author comment

Began life as a copy of #1035103

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036114
Snippet name: CloseableMapI - mapping iterator with closing
Eternal ID of this version: #1036114/1
Text MD5: 068ac55d1341e64e8f83c8817b7dd0a6
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-21 18:26:28
Source code size: 350 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 68 / 75
Referenced in: [show references]