List of usage examples for com.google.common.collect Lists newArrayListWithExpectedSize
@GwtCompatible(serializable = true) public static <E> ArrayList<E> newArrayListWithExpectedSize(int estimatedSize)
From source file:org.dslforge.xtext.common.scoping.BasicTextContainerManager.java
protected List<IContainer> getVisibleContainers(List<String> handles, IResourceDescriptions resourceDescriptions) { if (handles.isEmpty()) return Collections.emptyList(); List<IContainer> result = Lists.newArrayListWithExpectedSize(handles.size() + 1); String handle = internalGetContainerHandle(description, resourceDescriptions); IContainer container = newContainer(handle, resourceDescriptions); result.add(container);/* w ww. j a v a2 s . c o m*/ return result; }
From source file:com.android.tools.idea.gradle.structure.model.repositories.search.ArtifactRepositorySearch.java
@NotNull public Callback start(@NotNull SearchRequest request) { Callback callback = new Callback(); List<Future<SearchResult>> jobs = Lists.newArrayListWithExpectedSize(myRepositories.size()); List<SearchResult> results = Lists.newArrayList(); List<Exception> errors = Lists.newArrayList(); Application application = ApplicationManager.getApplication(); application.executeOnPooledThread(() -> { for (ArtifactRepository repository : myRepositories) { jobs.add(application.executeOnPooledThread(() -> repository.search(request))); }//w w w . j a v a2 s.c o m for (Future<SearchResult> job : jobs) { try { results.add(Futures.getChecked(job, Exception.class)); } catch (Exception e) { errors.add(e); } } callback.setDone(results, errors); }); return callback; }
From source file:com.android.tools.idea.tests.gui.framework.fixture.InspectionsFixture.java
private static void describe(@NotNull InspectionTreeNode node, @NotNull StringBuilder sb, int depth) { for (int i = 0; i < depth; i++) { sb.append(" "); }/*from ww w. ja v a 2 s . com*/ sb.append(node.toString()); sb.append("\n"); // The exact order of the results sometimes varies so sort the children alphabetically // instead to ensure stable test output List<InspectionTreeNode> children = Lists.newArrayListWithExpectedSize(node.getChildCount()); for (int i = 0, n = node.getChildCount(); i < n; i++) { children.add((InspectionTreeNode) node.getChildAt(i)); } Collections.sort(children, (node1, node2) -> node1.toString().compareTo(node2.toString())); for (InspectionTreeNode child : children) { describe(child, sb, depth + 1); } }
From source file:info.magnolia.ui.admincentral.shellapp.pulse.PulseMatchers.java
/** * Checks whether the provided list of Vaadin items is of expected size and contains valid message items * (i.e. contain properties described in {@link MessageConstants}). *//*from w w w . j a v a 2 s . com*/ public static Matcher<Iterable<? extends Item>> containsAmountOfMessageItems(int size) { final List<Matcher<? super Item>> matchers = Lists.newArrayListWithExpectedSize(size); for (int i = 0; i < size; ++i) { matchers.add(isMessageItem()); } return new IsIterableContainingInOrder<Item>(matchers); }
From source file:com.android.tools.idea.lint.AndroidLintIncludeLayoutParamInspection.java
@NotNull @Override/*ww w . j a v a 2 s. c om*/ public AndroidLintQuickFix[] getQuickFixes(@NotNull String message) { List<AndroidLintQuickFix> fixes = Lists.newArrayListWithExpectedSize(2); if (IncludeDetector.requestsWidth(message)) { fixes.add(new SetAttributeQuickFix("Set layout_width", ATTR_LAYOUT_WIDTH, null)); } if (IncludeDetector.requestsHeight(message)) { fixes.add(new SetAttributeQuickFix("Set layout_height", ATTR_LAYOUT_HEIGHT, null)); } return fixes.toArray(new AndroidLintQuickFix[fixes.size()]); }
From source file:org.apache.druid.guice.ListProvider.java
@Override public List<T> get() { List<T> retVal = Lists.newArrayListWithExpectedSize(itemsToLoad.size()); for (Key<? extends T> key : itemsToLoad) { retVal.add(injector.getInstance(key)); }/*from w ww. ja va 2 s .co m*/ return retVal; }
From source file:org.apache.kylin.cube.inmemcubing.ConsumeBlockingQueueController.java
public ConsumeBlockingQueueController(BlockingQueue<T> input, int batchSize) { this.input = input; this.batchSize = batchSize; this.batchBuffer = Lists.newArrayListWithExpectedSize(batchSize); this.internalIT = batchBuffer.iterator(); }
From source file:com.cloudera.exhibit.hive.ArrayUnionUDF.java
@Override public ObjectInspector initialize(ObjectInspector[] args) throws UDFArgumentException { if (args.length < 2) { throw new UDFArgumentException("Expecting at least two arguments to array_union"); }// ww w. jav a 2s . c o m this.argOIs = Lists.newArrayListWithExpectedSize(args.length); ObjectInspector elemOI = null; for (ObjectInspector oi : args) { ListObjectInspector loi = (ListObjectInspector) oi; argOIs.add(loi); ObjectInspector eoi = ObjectInspectorUtils .getStandardObjectInspector(loi.getListElementObjectInspector()); if (elemOI == null) { elemOI = eoi; } else if (!elemOI.equals(eoi)) { throw new UDFArgumentException("Array elements must all be of the same type"); } } return ObjectInspectorFactory.getStandardListObjectInspector(elemOI); }
From source file:ru.codeinside.gses.webui.data.OwnHistoryBeanQuery.java
@Override public List<Item> loadItems(final int startIndex, final int count) { List<Bid> bidIds = Flash.flash().getAdminService().bidsByLogin(Flash.login(), startIndex, count, sortProps, sortAsc, container.sender);// www.ja v a 2s. c om final List<Item> items = Lists.newArrayListWithExpectedSize(bidIds.size()); for (Bid bid : bidIds) { items.add(createItem(bid)); } return items; }
From source file:ru.codeinside.gses.webui.supervisor.GroupMembersQuery.java
@Override public List<Item> loadItems(int startIndex, int count) { List<Employee> members = mode == Mode.ORG ? Flash.flash().getAdminService().getOrgGroupMembers(groupName, taskId, startIndex, count) : Flash.flash().getAdminService().getEmpGroupMembers(groupName, taskId, startIndex, count); List<Item> items = Lists.newArrayListWithExpectedSize(members.size()); for (Employee e : members) { PropertysetItem item = new PropertysetItem(); item.addItemProperty("login", new ObjectProperty<String>(e.getLogin())); item.addItemProperty("fio", new ObjectProperty<String>(e.getFio())); items.add(item);/*from w ww .j a va 2 s. c o m*/ } return items; }