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 java.util.function.*;
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 java.awt.geom.*;
import javax.imageio.*;
import java.math.*;
import java.time.Duration;
import static x30_pkg.x30_util.DynamicObject;
import java.awt.datatransfer.StringSelection;
import java.text.*;
import java.text.NumberFormat;
import java.util.TimeZone;
import java.awt.geom.*;
import javax.swing.Icon;
import java.nio.file.Path;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
class main {
static class BStackComputeAllWithPrintStruct implements IFieldsToList{
VStack.Computable f;
BStackComputeAllWithPrintStruct() {}
BStackComputeAllWithPrintStruct(VStack.Computable f) {
this.f = f;}
public String toString() { return shortClassName_dropNumberPrefix(this) + "(" + f + ")"; }public Object[] _fieldsToList() { return new Object[] {f}; }
final public BStackComputeAllWithPrintStruct setMaxBacktracks(int maxBacktracks){ return maxBacktracks(maxBacktracks); }
public BStackComputeAllWithPrintStruct maxBacktracks(int maxBacktracks) { this.maxBacktracks = maxBacktracks; return this; } final public int getMaxBacktracks(){ return maxBacktracks(); }
public int maxBacktracks() { return maxBacktracks; }
int maxBacktracks = 10;
final public BStackComputeAllWithPrintStruct setMaxStepsPerBacktrack(int maxStepsPerBacktrack){ return maxStepsPerBacktrack(maxStepsPerBacktrack); }
public BStackComputeAllWithPrintStruct maxStepsPerBacktrack(int maxStepsPerBacktrack) { this.maxStepsPerBacktrack = maxStepsPerBacktrack; return this; } final public int getMaxStepsPerBacktrack(){ return maxStepsPerBacktrack(); }
public int maxStepsPerBacktrack() { return maxStepsPerBacktrack; }
int maxStepsPerBacktrack = 10;
final public List getResults(){ return results(); }
public List results() { return results; }
List results = new ArrayList();
final public BStackComputeAllWithPrintStruct setStack(IBStack stack){ return stack(stack); }
public BStackComputeAllWithPrintStruct stack(IBStack stack) { this.stack = stack; return this; } final public IBStack getStack(){ return stack(); }
public IBStack stack() { return stack; }
IBStack stack;
BStackComputeAllWithPrintStruct(IBStack stack, VStack.Computable f) {
this.f = f;
this.stack = stack;}
List get() {
// Make a stack with our computation
if (stack == null)
stack = new BStack(f);
else
stack.push(f);
for (int _repeat_0 = 0; _repeat_0 < maxBacktracks; _repeat_0++) {
// Get first or next result of function
A result = stack.nextResultWithPrintStruct(maxStepsPerBacktrack);
results.add(result);
print("Result: " + result);
// Ask the stack to backtrack to get another result
stack = stack.backtrack();
// If there is no more result, print message and exit
if (stack == null) {
print("No further result");
break;
}
// There is another result, so continue loop
}
return results;
}
}
static String shortClassName_dropNumberPrefix(Object o) {
return dropNumberPrefix(shortClassName(o));
}
static JPanel stack(Object... parts) {
return vstack2(parts);
}
// get purpose 1: access a list/array/map (safer version of x.get(y))
static A get(List l, int idx) {
return l != null && idx >= 0 && idx < l(l) ? l.get(idx) : null;
}
// seems to conflict with other signatures
/*static B get(Map map, A key) {
ret map != null ? map.get(key) : null;
}*/
static A get(A[] l, int idx) {
return idx >= 0 && idx < l(l) ? l[idx] : null;
}
// default to false
static boolean get(boolean[] l, int idx) {
return idx >= 0 && idx < l(l) ? l[idx] : false;
}
// get purpose 2: access a field by reflection or a map
static Object get(Object o, String field) {
try {
if (o == null) return null;
if (o instanceof Class) return get((Class) o, field);
if (o instanceof Map)
return ((Map) o).get(field);
Field f = getOpt_findField(o.getClass(), field);
if (f != null) {
makeAccessible(f);
return f.get(o);
}
if (o instanceof DynamicObject)
return getOptDynOnly(((DynamicObject) o), field);
} catch (Exception e) {
throw asRuntimeException(e);
}
throw new RuntimeException("Field '" + field + "' not found in " + o.getClass().getName());
}
static Object get_raw(String field, Object o) {
return get_raw(o, field);
}
static Object get_raw(Object o, String field) { try {
if (o == null) return null;
Field f = get_findField(o.getClass(), field);
makeAccessible(f);
return f.get(o);
} catch (Exception __e) { throw rethrow(__e); } }
static Object get(Class c, String field) {
try {
Field f = get_findStaticField(c, field);
makeAccessible(f);
return f.get(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
static Field get_findStaticField(Class> c, String field) {
Class _c = c;
do {
for (Field f : _c.getDeclaredFields())
if (f.getName().equals(field) && (f.getModifiers() & java.lang.reflect.Modifier.STATIC) != 0)
return f;
_c = _c.getSuperclass();
} while (_c != null);
throw new RuntimeException("Static field '" + field + "' not found in " + c.getName());
}
static Field get_findField(Class> c, String field) {
Class _c = c;
do {
for (Field f : _c.getDeclaredFields())
if (f.getName().equals(field))
return f;
_c = _c.getSuperclass();
} while (_c != null);
throw new RuntimeException("Field '" + field + "' not found in " + c.getName());
}
static Object get(String field, Object o) {
return get(o, field);
}
static boolean get(BitSet bs, int idx) {
return bs != null && bs.get(idx);
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static boolean printAlsoToSystemOut = true;
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