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).

static <A> ItIt<A> iterateUpdatingProgressShower(IProgressShower progressBar, Collection<A> l) {
  if (progressBar == null) ret iterableIterator(l);
  ret iteratorFromFunction_withEndMarker_f0(new F0 {
    int n = l(l), i;
    Iterator<A> it = iterator(l);
    NotTooOften nto = onlyTenTimesASecond();
    
    { progressBar.setTotal(n); }
    
    void update {
      progressBar.setValue(i);
      progressBar.setText(i + " / " + n);
    }
    
    public O get() {
      if (!it.hasNext()) {
        i = n;
        update();
        ret endMarker();
      }
      if (nto.yo()) update();
      ++i;
      ret it.next();
    }
  });
}

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: 184 / 278
Version history: 7 change(s)
Referenced in: [show references]