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.

1  
static boolean empty(Collection c) { ret c == null || c.isEmpty(); }
2  
static boolean empty(Iterable c) { ret c == null || !c.iterator().hasNext(); }
3  
static boolean empty(CharSequence s) { ret s == null || s.length() == 0; }
4  
static boolean empty(Map map) { ret map == null || map.isEmpty(); }
5  
static boolean empty(O[] o) { ret o == null || o.length == 0; }
6  
sbool empty(BitSet bs) { ret bs == null || bs.isEmpty(); }
7  
8  
ifndef empty_noGeneric
9  
static boolean empty(O o) {
10  
  if (o instanceof Collection) ret empty((Collection) o);
11  
  if (o instanceof S) ret empty((S) o);
12  
  if (o instanceof Map) ret empty((Map) o);
13  
  if (o instanceof O[]) ret empty((O[]) o);
14  
  if (o instanceof byte[]) ret empty((byte[]) o);
15  
  if (o == null) true;
16  
  throw fail("unknown type for 'empty': " + getType(o));
17  
}
18  
endifndef
19  
20  
sbool empty(Iterator i) { ret i == null || !i.hasNext(); }
21  
22  
static bool empty(double[] a) { ret a == null || a.length == 0; }
23  
static bool empty(float[] a) { ret a == null || a.length == 0; }
24  
static bool empty(int[] a) { ret a == null || a.length == 0; }
25  
static bool empty(long[] a) { ret a == null || a.length == 0; }
26  
static bool empty(byte[] a) { ret a == null || a.length == 0; }
27  
static bool empty(short[] a) { ret a == null || a.length == 0; }
28  
29  
ifclass MultiSet
30  
static bool empty(MultiSet ms) { ret ms == null || ms.isEmpty(); }
31  
endif
32  
33  
ifclass IMultiMap
34  
static bool empty(IMultiMap mm) { ret mm == null || mm.size() == 0; }
35  
endif
36  
37  
sbool empty(File f) { ret getFileSize(f) == 0; }
38  
39  
ifclass IntRange
40  
sbool empty(IntRange r) { ret r == null || r.empty(); }
41  
endif
42  
43  
ifclass DoubleRange
44  
sbool empty(DoubleRange r) { ret r == null || r.isEmpty(); }
45  
endif
46  
47  
ifclass IntBuffer
48  
sbool empty(IntBuffer b) { ret b == null || b.isEmpty(); }
49  
endif
50  
51  
ifclass LongBuffer
52  
sbool empty(LongBuffer b) { ret b == null || b.isEmpty(); }
53  
endif
54  
55  
ifclass SynchronizedLongBuffer
56  
sbool empty(SynchronizedLongBuffer b) { ret b == null || b.isEmpty(); }
57  
endif
58  
59  
ifclass DoubleBuffer
60  
sbool empty(DoubleBuffer b) { ret b == null || b.isEmpty(); }
61  
endif
62  
63  
ifclass SynchronizedDoubleBuffer
64  
sbool empty(SynchronizedDoubleBuffer b) { ret b == null || b.isEmpty(); }
65  
endif
66  
67  
ifclass SynchronizedFloatBufferPresentingAsDoubles
68  
sbool empty(SynchronizedFloatBufferPresentingAsDoubles b) { ret b == null || b.isEmpty(); }
69  
endif
70  
71  
ifclass IDoubleBuffer
72  
sbool empty(IDoubleBuffer b) { ret b == null || b.isEmpty(); }
73  
endif
74  
75  
ifclass ILongBuffer
76  
sbool empty(ILongBuffer b) { ret b == null || b.isEmpty(); }
77  
endif
78  
79  
ifclass Rect
80  
sbool empty(Rect r) { ret !(r != null && r.w != 0 && r.h != 0); }
81  
endif
82  
83  
ifclass Chain
84  
sbool empty(Chain c) { ret c == null; }
85  
endif
86  
87  
ifclass AppendableChain
88  
sbool empty(AppendableChain c) { ret c == null; }
89  
endif
90  
91  
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: 1229 / 6311
Version history: 31 change(s)
Referenced in: [show references]