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

91
LINES

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

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

Transpiled version (9627L) is out of date.

static boolean empty(Collection c) { ret c == null || c.isEmpty(); }
static boolean empty(Iterable c) { ret c == null || !c.iterator().hasNext(); }
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; }
sbool empty(BitSet bs) { ret bs == null || bs.isEmpty(); }

ifndef empty_noGeneric
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));
}
endifndef

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

static bool empty(double[] a) { ret a == null || a.length == 0; }
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

ifclass IMultiMap
static bool empty(IMultiMap mm) { ret mm == null || mm.size() == 0; }
endif

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

ifclass IntRange
sbool empty(IntRange r) { ret r == null || r.empty(); }
endif

ifclass DoubleRange
sbool empty(DoubleRange r) { ret r == null || r.isEmpty(); }
endif

ifclass IntBuffer
sbool empty(IntBuffer b) { ret b == null || b.isEmpty(); }
endif

ifclass LongBuffer
sbool empty(LongBuffer b) { ret b == null || b.isEmpty(); }
endif

ifclass SynchronizedLongBuffer
sbool empty(SynchronizedLongBuffer b) { ret b == null || b.isEmpty(); }
endif

ifclass DoubleBuffer
sbool empty(DoubleBuffer b) { ret b == null || b.isEmpty(); }
endif

ifclass SynchronizedDoubleBuffer
sbool empty(SynchronizedDoubleBuffer b) { ret b == null || b.isEmpty(); }
endif

ifclass SynchronizedFloatBufferPresentingAsDoubles
sbool empty(SynchronizedFloatBufferPresentingAsDoubles b) { ret b == null || b.isEmpty(); }
endif

ifclass IDoubleBuffer
sbool empty(IDoubleBuffer b) { ret b == null || b.isEmpty(); }
endif

ifclass ILongBuffer
sbool empty(ILongBuffer b) { ret b == null || b.isEmpty(); }
endif

ifclass Rect
sbool empty(Rect r) { ret !(r != null && r.w != 0 && r.h != 0); }
endif

ifclass Chain
sbool empty(Chain c) { ret c == null; }
endif

ifclass AppendableChain
sbool empty(AppendableChain c) { ret c == null; }
endif

sbool empty(IntSize l) { ret l == null || l.size() == 0; }

Author comment

Began life as a copy of #1002022

download  show line numbers  debug dex  old transpilations   

Travelled to 21 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, ekrmjmnbrukm, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1002108
Snippet name: empty - extended synonym of isEmpty
Eternal ID of this version: #1002108/32
Text MD5: 923d85521577d322b2a88e01a0ffab93
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-08 14:04:02
Source code size: 2837 bytes / 91 lines
Pitched / IR pitched: No / No
Views / Downloads: 1045 / 6085
Version history: 31 change(s)
Referenced in: [show references]