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

26
LINES

< > BotCompany Repo | #1027232 // iterateUpdatingProgressShower

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

Libraryless. Click here for Pure Java version (2353L/15K).

1  
static <A> ItIt<A> iterateUpdatingProgressShower(IProgressShower progressBar, Collection<A> l) {
2  
  if (progressBar == null) ret iterableIterator(l);
3  
  ret iteratorFromFunction_withEndMarker_f0(new F0 {
4  
    int n = l(l), i;
5  
    Iterator<A> it = iterator(l);
6  
    NotTooOften nto = onlyTenTimesASecond();
7  
    
8  
    { progressBar.setTotal(n); }
9  
    
10  
    void update {
11  
      progressBar.setValue(i);
12  
      progressBar.setText(i + " / " + n);
13  
    }
14  
    
15  
    public O get() {
16  
      if (!it.hasNext()) {
17  
        i = n;
18  
        update();
19  
        ret endMarker();
20  
      }
21  
      if (nto.yo()) update();
22  
      ++i;
23  
      ret it.next();
24  
    }
25  
  });
26  
}

Author comment

Began life as a copy of #1024797

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: #1027232
Snippet name: iterateUpdatingProgressShower
Eternal ID of this version: #1027232/8
Text MD5: 7775a2a0b0f9c29dc3ca93d55f178f16
Transpilation MD5: 9d409a497f1ac846fc8f57e7f6001180
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-26 14:44:04
Source code size: 661 bytes / 26 lines
Pitched / IR pitched: No / No
Views / Downloads: 186 / 281
Version history: 7 change(s)
Referenced in: [show references]