import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
class main {
public static void main(final String[] args) throws Exception {
// ll method
for (int n = 0; n <= 10; n++) {
Object[] data = repArrayF("aGlobalID", n);
Object l = smallestList_ll(data);
check(data, l);
}
// add method
Object l = null;
Object[] data = new Object[0];
for (int n = 0; n <= 10; n++) {
check(data, l);
data = addToObjectArray(data, aGlobalID());
l = smallestList_add(l, last(data));
}
print("OK!");
}
static void check(Object[] data, Object l) {
int n = l(data);
print("Size " + n + ": " + sfu(l));
assertEquals(n, smallestList_l(l));
for (int i = 0; i < n; i++)
assertEquals(data[i], smallestList_get(l, i));
assertEquals(asList(data), new ArrayList(smallestList_asList(l)));
int size = 0;
if (l != null)
if (l instanceof String) size = 0;
else size = toInt(unsafe_sizeOf(l));
print("Bytes used for list: " + size + " bytes");
printStruct(unsafe_allFieldOffsets(l));
}
static String aGlobalID() {
return randomID(globalIDLength());
}
static String aGlobalID(Random random) {
return randomID(random, globalIDLength());
}
static Object[] repArrayF(int n, Object f, Object... args) {
Object[] o = new Object[n];
for (int i = 0; i < n; i++)
o[i] = callF(f, args);
return o;
}
static Object[] repArrayF(Object f, int n) {
return repArrayF(n, f);
}
static Object smallestList_ll(Object... e) {
int n = l(e);
smallestList_checkElements(e);
switch (n) {
case 0: return null;
case 1: return e[0];
case 2: return pair(e[0], e[1]);
case 3: return triple(e[0], e[1], e[2]);
default: return cloneObjectArray(e);
}
}
static Object[] addToObjectArray(Object[] a, Object o) {
Object[] x = new Object[l(a)+1];
arraycopy(a, 0, x, 0, l(a));
x[l(a)] = o;
return x;
}
static Object smallestList_add(Object l, Object o) {
if (l == null) return o;
if (l instanceof Pair) return triple(((Pair) l).a, ((Pair) l).b, o);
if (l instanceof T3) return new Object[] {((T3) l).a, ((T3) l).b, ((T3) l).c, o};
if (l instanceof Object[]) return addToObjectArray(((Object[]) l), o);
return pair(l, o);
}
static A last(List l) {
return empty(l) ? null : l.get(l.size()-1);
}
static char last(String s) {
return empty(s) ? '#' : s.charAt(l(s)-1);
}
static int last(int[] a) {
return l(a) != 0 ? a[l(a)-1] : 0;
}
static double last(double[] a) {
return l(a) != 0 ? a[l(a)-1] : 0;
}
static A last(A[] a) {
return l(a) != 0 ? a[l(a)-1] : null;
}
static A last(Iterator it) {
A a = null;
while (it.hasNext()) { ping(); a = it.next(); }
return a;
}
static A last(Collection l) {
if (l == null) return null;
if (l instanceof List) return (A) last(((List) l));
if (l instanceof SortedSet) return (A) last(((SortedSet) l));
Iterator it = iterator(l);
A a = null;
while (it.hasNext()) { ping(); a = it.next(); }
return a;
}
static A last(SortedSet l) {
return l == null ? null : l.last();
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static volatile Appendable print_log = local_log; // might be redirected, e.g. to main bot
// in bytes - will cut to half that
static volatile int print_log_max = 1024*1024;
static volatile int local_log_max = 100*1024;
static boolean print_silent = false; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal