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

29
LINES

< > BotCompany Repo | #1003859 // containsOneOf - possibly slow with array as 2nd argument; fast with Set

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

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

// unclear semantics when l is a special set (e.g. ciSet)

static <A> bool containsOneOf(Collection<A> l, A... x) {
  if (l instanceof Set) {
    if (x != null)
      for (A a : x)
        if (l.contains(a))
          true;
  } else {
    for (A a : unnull(l))
      if (eqOneOf(a, x))
        true;
  }
  false;
}

static <A> bool containsOneOf(Collection<A> l, Set<A> set) {
  if (set == null) false;
  for (A a : unnull(l))
    if (set.contains(a))
      true;
  false;
}

static bool containsOneOf(S s, S... x) {
  for (S o : x)
    if (contains(s, o)) true;
  false;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1003859
Snippet name: containsOneOf - possibly slow with array as 2nd argument; fast with Set
Eternal ID of this version: #1003859/9
Text MD5: 84965dbb1088def45e1c19dfd54bc25d
Transpilation MD5: cfb00185f39a27c6b5f305361fcf7644
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-05 00:50:26
Source code size: 601 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 595 / 623
Version history: 8 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1014459 - containsOneOfIC