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

18
LINES

< > BotCompany Repo | #1011433 // filterByField_smart - avoids making an unnecessary list

JavaX fragment (include)

static <A> Collection<A> filterByField_smart(Collection<A> l, S field, O value) {
  if (l == null) null;
  for (A n : l)
    if (!eq(getOpt(n, field), value)) {
      Iterator<A> it = iterator(l);
      A node;
      new L<A> x;
      while ((node = it.next()) != n)
        x.add(node);
      while (it.hasNext()) {
        node = it.next();
        if (eq(getOpt(node, field), value))
          x.add(node);
      }
      ret x;
    }
  ret l;
}

Author comment

Began life as a copy of #1002319

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011433
Snippet name: filterByField_smart - avoids making an unnecessary list
Eternal ID of this version: #1011433/3
Text MD5: 5d2809917feb380020a9b08ed7cf7102
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-29 02:36:51
Source code size: 464 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 379 / 375
Version history: 2 change(s)
Referenced in: [show references]