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.*;
import java.text.NumberFormat;
import static x30_pkg.x30_util.DynamicObject;
class main {
static class Test_CompactLinkedHashSet {
LinkedHashSet a = new LinkedHashSet();
CompactLinkedHashSet b = new CompactLinkedHashSet();
int n = 1000, valueRange = 10;
Object makeEntry() { return random(valueRange); }
boolean remove = true;
public void run() {
for (int _repeat_0 = 0; _repeat_0 < n; _repeat_0++) {
addToTwoCollections(a, b, makeEntry());
if (remove) removeFromTwoCollections(a, b, makeEntry());
print(n2(a) + " - " + takeFirst(10, a.iterator()));
assertEquals(asList(a.iterator()), asList(b.iterator()));
print("Size LinkedHashSet: " + n2(deepObjectSize(a))
+ ", size CompactLinkedHashSet: " + n2(deepObjectSize(b)));
}
}
}
static void test_CompactLinkedHashSet() {
new Test_CompactLinkedHashSet().run();
}
static Random random_random = new Random();
static int random(int n) {
return random(random_random, n);
}
static int random(int n, Random r) { return random(r, n); }
static int random(Random r, int n) {
return n <= 0 ? 0 : r.nextInt(n);
}
static double random(double max) {
return random()*max;
}
static double random() {
return random_random.nextInt(100001)/100000.0;
}
static double random(double min, double max) {
return min+random()*(max-min);
}
// min <= value < max
static int random(int min, int max) {
return min+random(max-min);
}
static int random(int min, int max, Random r) {
return random(r, min, max);
}
static int random(Random r, int min, int max) {
return min+random(r, max-min);
}
static A random(List l) {
return oneOf(l);
}
static A random(Collection c) {
if (c instanceof List) return random((List) c);
int i = random(l(c));
return collectionGet(c, i);
}
static Pair random(Map map) {
return entryToPair(random(entries(map)));
}
static boolean addToTwoCollections(Collection c1, Collection c2, A a) {
boolean change = false;
if (c1 != null && c1.add(a)) change = true;
if (c2 != null && c2.add(a)) change = true;
return change;
}
static boolean removeFromTwoCollections(Collection c1, Collection c2, A a) {
boolean change = false;
if (c1 != null && c1.remove(a)) change = true;
if (c2 != null && c2.remove(a)) change = true;
return change;
}
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