use of suite.primitive.IntMutable in project suite by stupidsing.
the class RunUtil method run.
public static void run(Class<? extends ExecutableProgram> clazz, String[] args, RunOption runOption) {
LogUtil.initLog4j(Level.INFO);
IntMutable mutableCode = IntMutable.nil();
IntSource source = () -> {
try {
try (ExecutableProgram main_ = Object_.new_(clazz)) {
return main_.run(args) ? 0 : 1;
}
} catch (Throwable ex) {
ex.printStackTrace();
LogUtil.fatal(ex);
return 2;
}
};
Runnable runnable = () -> mutableCode.set(source.source());
switch(runOption) {
case PROFILE:
new Profiler().profile(runnable);
break;
case RUN____:
runnable.run();
break;
case TIME___:
LogUtil.duration(clazz.getSimpleName(), () -> {
runnable.run();
return Boolean.TRUE;
});
}
int code = mutableCode.get();
if (code != 0)
System.exit(code);
}
use of suite.primitive.IntMutable in project suite by stupidsing.
the class DevMain method text.
private Text text(IRopeList<Character> text) {
IntsBuilder starts = new IntsBuilder();
IntsBuilder ends = new IntsBuilder();
IntMutable p0 = IntMutable.of(-1);
int size = text.size();
IntSink lf = px -> {
starts.append(p0.get() + 1);
ends.append(px);
p0.update(px);
};
for (int p = 0; p < size; p++) {
char ch = text.get(p);
if (ch == '\n' || wrapSize < p - p0.get())
lf.sink(p);
}
if (1 < size - p0.get())
lf.sink(size);
return new Text(text, starts.toInts().toArray(), ends.toInts().toArray());
}
Aggregations