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

23
LINES

< > BotCompany Repo | #1002990 - contains - like Collection.contains, but allows a null collection and arrays. also for strings

JavaX fragment (include)

static bool contains(Collection c, O o) {
  ret c != null && c.contains(o);
}

static bool contains(O[] x, O o) {
  if (x != null)
    for (O a : x)
      if (eq(a, o))
        ret true;
  ret false;
}

static bool contains(S s, char c) {
  ret s != null && s.indexOf(c) >= 0;
}

static bool contains(S s, S b) {
  ret s != null && s.indexOf(b) >= 0;
}

static bool contains(BitSet bs, int i) {
  ret bs != null && bs.get(i);
}

Author comment

Began life as a copy of #1002148

download  show line numbers  debug dex   

Travelled to 11 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, podlckwnjdmb, sawdedvomwva, tslmcundralx, tvejysmllsmz

No comments. add comment

Snippet ID: #1002990
Snippet name: contains - like Collection.contains, but allows a null collection and arrays. also for strings
Eternal ID of this version: #1002990/2
Text MD5: de553035a2b4f328e4d00d76d38c4a77
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-01 14:25:38
Source code size: 449 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 434 / 1181
Version history: 1 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1002990 & http://1002990.tinybrain.de