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

60
LINES

< > BotCompany Repo | #1001518 - l function (synonym of length), length of arrays, strings, lists, size of maps

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

Transpiled version (2475L) is out of date.

1  
static int l(Object[] a) { return a == null ? 0 : a.length; }
2  
static int l(bool[] a) { return a == null ? 0 : a.length; }
3  
static int l(byte[] a) { return a == null ? 0 : a.length; }
4  
static int l(short[] a) { return a == null ? 0 : a.length; }
5  
static int l(long[] a) { return a == null ? 0 : a.length; }
6  
static int l(int[] a) { return a == null ? 0 : a.length; }
7  
static int l(float[] a) { return a == null ? 0 : a.length; }
8  
static int l(double[] a) { return a == null ? 0 : a.length; }
9  
static int l(char[] a) { return a == null ? 0 : a.length; }
10  
static int l(Collection c) { return c == null ? 0 : c.size(); }
11  
ifndef l_noIterators
12  
static int l(Iterator i) { return iteratorCount_int_close(i); } // consumes the iterator && closes it if possible
13  
endifndef
14  
static int l(Map m) { return m == null ? 0 : m.size(); }
15  
static int l(CharSequence s) { return s == null ? 0 : s.length(); }
16  
static long l(File f) { ret f == null ? 0 : f.length(); }
17  
18  
ifndef l_withoutReflection
19  
20  
static int l(Object o) {
21  
  ret o == null ? 0
22  
    : o instanceof S ? l((S) o)
23  
    : o instanceof Map ? l((Map) o)
24  
    : o instanceof Collection ? l((Collection) o)
25  
    : o instanceof O[] ? l((O[]) o)
26  
    : o instanceof bool[] ? l((bool[]) o)
27  
    : o instanceof byte[] ? l((byte[]) o)
28  
    : o instanceof char[] ? l((char[]) o)
29  
    : o instanceof short[] ? l((short[]) o)
30  
    : o instanceof int[] ? l((int[]) o)
31  
    : o instanceof float[] ? l((float[]) o)
32  
    : o instanceof double[] ? l((double[]) o)
33  
    : o instanceof long[] ? l((long[]) o)
34  
    : (Int) call(o, 'size);
35  
}
36  
endifndef
37  
38  
ifclass MultiSet
39  
  static int l(MultiSet ms) { ret ms == null ? 0 : ms.size(); }
40  
endif
41  
42  
ifclass Lisp
43  
  static int l(Lisp l) { ret l == null ? 0 : l.size(); }
44  
endif
45  
46  
ifclass IntRange
47  
  static int l(IntRange r) { ret r == null ? 0 : r.length(); }
48  
endif
49  
50  
ifclass LongRange
51  
  static long l(LongRange r) { ret r == null ? 0 : r.length(); }
52  
endif
53  
54  
ifclass IntBuffer
55  
  static int l(IntBuffer b) { ret b == null ? 0 : b.size(); }
56  
endif
57  
58  
ifclass LongBuffer
59  
  static int l(LongBuffer b) { ret b == null ? 0 : b.size(); }
60  
endif

Author comment

Began life as a copy of #1001516

download  show line numbers  debug dex   

Travelled to 20 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lnbujpyubztb, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, podlckwnjdmb, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, whxojlpjdney, wtqryiryparv, xrpafgyirdlv, yanjaxplzisb

No comments. add comment

Snippet ID: #1001518
Snippet name: l function (synonym of length), length of arrays, strings, lists, size of maps
Eternal ID of this version: #1001518/27
Text MD5: 802b6931297a2f9ffdd12e4ac92a470d
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-08-02 00:56:22
Source code size: 2125 bytes / 60 lines
Pitched / IR pitched: No / No
Views / Downloads: 752 / 9224
Version history: 26 change(s)
Referenced in: [show references]

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