use of java.util.TreeSet in project android_frameworks_base by ParanoidAndroid.
the class WritePreloadedClassFile method main.
public static void main(String[] args) throws IOException, ClassNotFoundException {
if (args.length != 1) {
System.err.println("Usage: WritePreloadedClassFile [compiled log]");
System.exit(-1);
}
String rootFile = args[0];
Root root = Root.fromFile(rootFile);
// No classes are preloaded to start.
for (LoadedClass loadedClass : root.loadedClasses.values()) {
loadedClass.preloaded = false;
}
// Open preloaded-classes file for output.
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(Policy.PRELOADED_CLASS_FILE), Charset.forName("US-ASCII")));
out.write("# Classes which are preloaded by" + " com.android.internal.os.ZygoteInit.\n");
out.write("# Automatically generated by frameworks/base/tools/preload/" + WritePreloadedClassFile.class.getSimpleName() + ".java.\n");
out.write("# MIN_LOAD_TIME_MICROS=" + MIN_LOAD_TIME_MICROS + "\n");
out.write("# MIN_PROCESSES=" + MIN_PROCESSES + "\n");
/*
* The set of classes to preload. We preload a class if:
*
* a) it's loaded in the bootclasspath (i.e., is a system class)
* b) it takes > MIN_LOAD_TIME_MICROS us to load, and
* c) it's loaded by more than one process, or it's loaded by an
* application (i.e., not a long running service)
*/
Set<LoadedClass> toPreload = new TreeSet<LoadedClass>();
// the memory associated with these classes will be shared.
for (LoadedClass loadedClass : root.loadedClasses.values()) {
Set<String> names = loadedClass.processNames();
if (!Policy.isPreloadable(loadedClass)) {
continue;
}
if (names.size() >= MIN_PROCESSES || (loadedClass.medianTimeMicros() > MIN_LOAD_TIME_MICROS && names.size() > 1)) {
toPreload.add(loadedClass);
}
}
int initialSize = toPreload.size();
System.out.println(initialSize + " classses were loaded by more than one app.");
// services).
for (Proc proc : root.processes.values()) {
if (proc.fromZygote() && !Policy.isService(proc.name)) {
for (Operation operation : proc.operations) {
LoadedClass loadedClass = operation.loadedClass;
if (shouldPreload(loadedClass)) {
toPreload.add(loadedClass);
}
}
}
}
System.out.println("Added " + (toPreload.size() - initialSize) + " more to speed up applications.");
System.out.println(toPreload.size() + " total classes will be preloaded.");
// Make classes that were implicitly loaded by the zygote explicit.
// This adds minimal overhead but avoid confusion about classes not
// appearing in the list.
addAllClassesFrom("zygote", root, toPreload);
for (LoadedClass loadedClass : toPreload) {
out.write(loadedClass.name + "\n");
}
out.close();
// Update data to reflect LoadedClass.preloaded changes.
for (LoadedClass loadedClass : toPreload) {
loadedClass.preloaded = true;
}
root.toFile(rootFile);
}
use of java.util.TreeSet in project LogisticsPipes by RS485.
the class PipeLogisticsChassi method getSpecificInterests.
@Override
public Set<ItemIdentifier> getSpecificInterests() {
Set<ItemIdentifier> l1 = new TreeSet<>();
//if we don't have a pointed inventory we can't be interested in anything
if (getRealInventory() == null) {
return l1;
}
for (int moduleIndex = 0; moduleIndex < getChassiSize(); moduleIndex++) {
LogisticsModule module = _module.getSubModule(moduleIndex);
if (module != null && module.interestedInAttachedInventory()) {
IInventoryUtil inv = getSneakyInventory(false, module.getSlot(), module.getPositionInt());
if (inv == null) {
continue;
}
Set<ItemIdentifier> items = inv.getItems();
l1.addAll(items);
//also add tag-less variants ... we should probably add a module.interestedIgnoringNBT at some point
l1.addAll(items.stream().map(ItemIdentifier::getIgnoringNBT).collect(Collectors.toList()));
boolean modulesInterestedInUndamged = false;
for (int i = 0; i < getChassiSize(); i++) {
if (_module.getSubModule(moduleIndex).interestedInUndamagedID()) {
modulesInterestedInUndamged = true;
break;
}
}
if (modulesInterestedInUndamged) {
l1.addAll(items.stream().map(ItemIdentifier::getUndamaged).collect(Collectors.toList()));
}
// no need to check other modules for interest in the inventory, when we know that 1 already is.
break;
}
}
for (int i = 0; i < getChassiSize(); i++) {
LogisticsModule module = _module.getSubModule(i);
if (module != null) {
Collection<ItemIdentifier> current = module.getSpecificInterests();
if (current != null) {
l1.addAll(current);
}
}
}
return l1;
}
use of java.util.TreeSet in project LogisticsPipes by RS485.
the class AEInterfaceInventoryHandler method getItems.
@Override
public Set<ItemIdentifier> getItems() {
Set<ItemIdentifier> result = new TreeSet<>();
IStorageMonitorable tmp = tile.getMonitorable(dir, source);
if (tmp == null || tmp.getItemInventory() == null || tmp.getItemInventory().getStorageList() == null) {
return result;
}
for (IAEItemStack items : tmp.getItemInventory().getStorageList()) {
ItemIdentifier ident = ItemIdentifier.get(items.getItemStack());
result.add(ident);
}
return result;
}
use of java.util.TreeSet in project LogisticsPipes by RS485.
the class JABBAInventoryHandler method getItems.
@Override
public Set<ItemIdentifier> getItems() {
Set<ItemIdentifier> result = new TreeSet<>();
ItemStack items = _storage.getStoredItemType();
if (items != null) {
result.add(ItemIdentifier.get(items));
}
return result;
}
use of java.util.TreeSet in project generator by mybatis.
the class UpdateByPrimaryKeySelectiveMethodGenerator method addImplementationElements.
@Override
public void addImplementationElements(TopLevelClass topLevelClass) {
Set<FullyQualifiedJavaType> importedTypes = new TreeSet<FullyQualifiedJavaType>();
Method method = getMethodShell(importedTypes);
StringBuilder sb = new StringBuilder();
//$NON-NLS-1$
sb.append("int rows = ");
sb.append(daoTemplate.getUpdateMethod(introspectedTable.getIbatis2SqlMapNamespace(), introspectedTable.getUpdateByPrimaryKeySelectiveStatementId(), //$NON-NLS-1$
"record"));
method.addBodyLine(sb.toString());
//$NON-NLS-1$
method.addBodyLine("return rows;");
if (context.getPlugins().clientUpdateByPrimaryKeySelectiveMethodGenerated(method, topLevelClass, introspectedTable)) {
topLevelClass.addImportedTypes(importedTypes);
topLevelClass.addMethod(method);
}
}
Aggregations