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

27
LINES

< > BotCompany Repo | #1002108 - empty - extended synonym of isEmpty

JavaX fragment (include)

static boolean empty(Collection c) { ret c == null || c.isEmpty(); }
static boolean empty(CharSequence s) { ret s == null || s.length() == 0; }
static boolean empty(Map map) { ret map == null || map.isEmpty(); }
static boolean empty(O[] o) { ret o == null || o.length == 0; }
static boolean empty(O o) {
  if (o instanceof Collection) ret empty((Collection) o);
  if (o instanceof S) ret empty((S) o);
  if (o instanceof Map) ret empty((Map) o);
  if (o instanceof O[]) ret empty((O[]) o);
  if (o instanceof byte[]) ret empty((byte[]) o);
  if (o == null) true;
  throw fail("unknown type for 'empty': " + getType(o));
}

sbool empty(Iterator i) { ret i == null || !i.hasNext(); }

static bool empty(float[] a) { ret a == null || a.length == 0; }
static bool empty(int[] a) { ret a == null || a.length == 0; }
static bool empty(long[] a) { ret a == null || a.length == 0; }
static bool empty(byte[] a) { ret a == null || a.length == 0; }
static bool empty(short[] a) { ret a == null || a.length == 0; }

ifclass MultiSet
static bool empty(MultiSet ms) { ret ms == null || ms.isEmpty(); }
endif

sbool empty(File f) { ret getFileSize(f) == 0; }

Author comment

Began life as a copy of #1002022

download  show line numbers  debug dex   

Travelled to 14 computer(s): aoiabmzegqzx, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, sawdedvomwva, tslmcundralx, tvejysmllsmz, whxojlpjdney

No comments. add comment

Snippet ID: #1002108
Snippet name: empty - extended synonym of isEmpty
Eternal ID of this version: #1002108/11
Text MD5: ba71a36e5d1050ed659a6a414c7bd085
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-08-27 23:29:01
Source code size: 1170 bytes / 27 lines
Pitched / IR pitched: No / No
Views / Downloads: 604 / 5303
Version history: 10 change(s)
Referenced in: [show references]

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