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

16
LINES

< > BotCompany Repo | #1028060 // removeElementsThat - remove elements from collection matching a predicate

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

Libraryless. Click here for Pure Java version (2499L/16K).

// returns true if anything was removed
static <A> bool lambdaMapLike removeElementsThat(IPred<A> pred, Cl<A> c) {
  if (c == null || pred == null) false;
  Iterator<A> it = iterator(c);
  bool change;
  while (it.hasNext())
    if (pred.get(it.next())) {
      it.remove();
      set change;
    }
  ret change;
}

static <A> bool removeElementsThat(Cl<A> c, IPred<A> pred) {
  ret removeElementsThat(pred, c);
}

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: #1028060
Snippet name: removeElementsThat - remove elements from collection matching a predicate
Eternal ID of this version: #1028060/5
Text MD5: d3befb2f1dec046cbeadec697dbed1e5
Transpilation MD5: 5eaf8376985d63a551841fa3dbaee7f8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-05-15 12:40:30
Source code size: 428 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 191 / 285
Version history: 4 change(s)
Referenced in: [show references]