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

22
LINES

< > BotCompany Repo | #1024797 // iterateUpdatingProgressBar

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

Libraryless. Click here for Pure Java version (2240L/14K).

1  
static <A> ItIt<A> iterateUpdatingProgressBar(JProgressBar 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  
    public O get() {
9  
      if (!it.hasNext()) {
10  
        setProgressBarValue(progressBar, n, n);
11  
        setProgressBarText(progressBar, n + " / " + n);
12  
        ret endMarker();
13  
      }
14  
      if (nto.yo()) {
15  
        setProgressBarValue(progressBar, i, n);
16  
        setProgressBarText(progressBar, i + " / " + n);
17  
      }
18  
      ++i;
19  
      ret it.next();
20  
    }
21  
  });
22  
}

Author comment

Began life as a copy of #1020973

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1024797
Snippet name: iterateUpdatingProgressBar
Eternal ID of this version: #1024797/6
Text MD5: 65cb0c74e200fff195eaa1b0af704d83
Transpilation MD5: 88a26bb191f0ede56c6b6a011912c36c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-25 20:59:01
Source code size: 686 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 254 / 377
Version history: 5 change(s)
Referenced in: [show references]