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

9
LINES

< > BotCompany Repo | #1024814 // takeFirstI - cut off iterator after certain number of elements returned

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

Libraryless. Click here for Pure Java version (7976L/45K).

static <A> ItIt<A> takeFirstI(int n, Iterator<A> i) {
  ret i == null ? null : iff(new F0 {
    int remaining = n;
    
    O get() {
      ret remaining-- <= 0 || !i.hasNext() ? endMarker() : i.next();
    }
  });
}

Author comment

Began life as a copy of #1024189

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: #1024814
Snippet name: takeFirstI - cut off iterator after certain number of elements returned
Eternal ID of this version: #1024814/4
Text MD5: b456f150ec0306fa9aac82546ffe4bb1
Transpilation MD5: 7f1968d004c91ac042db906f22d0b11c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-26 12:23:25
Source code size: 224 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 189 / 278
Version history: 3 change(s)
Referenced in: [show references]