Refine search
private static final List removeDuplicates(List list) { int s = list.size(); ArrayList ulist = new ArrayList(s); Set set = new HashSet(s * 4 / 3, .75f); Iterator it = list.iterator(); while (it.hasNext()) { Object o = it.next(); if (set.add(o)) ulist.add(o); } ulist.trimToSize(); return ulist; }
List<ConsumerWithNode> getConsumers() { if (consumers == null) { consumers = new ArrayList<>(); for (DependencyNode node : domain) { if (node.followers != null) { consumers.add(new ConsumerWithNode(node.followers.toArray(new DependencyConsumer[0]), node)); } } consumers.trimToSize(); } return consumers; }
static <T> List<T> loadServices(Class<T> type, ClassLoader classLoader) { return doPrivileged((PrivilegedAction<List<T>>) () -> { ArrayList<T> list = new ArrayList<>(); Iterator<T> iterator = ServiceLoader.load(type, classLoader).iterator(); for (;;) try { if (! iterator.hasNext()) break; final T contextFactory = iterator.next(); list.add(contextFactory); } catch (ServiceConfigurationError error) { Messages.log.serviceConfigFailed(error); } list.trimToSize(); return list; }); }
/** * Returns text as a List of tokens. * * @return A list of all tokens remaining in the underlying Reader */ @Override public List<T> tokenize() { ArrayList<T> result = new ArrayList<>(DEFAULT_TOKENIZE_LIST_SIZE); while (hasNext()) { result.add(next()); } // log.info("tokenize() produced " + result); // if it was tiny, reallocate small if (result.size() <= DEFAULT_TOKENIZE_LIST_SIZE / 4) { result.trimToSize(); } return result; }
/** * Construct a new instance. The given class loader is scanned for transaction providers. * * @param classLoader the class loader to scan for transaction providers ({@code null} indicates the application or bootstrap class loader) */ public RemoteTransactionContext(final ClassLoader classLoader) { this(doPrivileged((PrivilegedAction<List<RemoteTransactionProvider>>) () -> { final ServiceLoader<RemoteTransactionProvider> loader = ServiceLoader.load(RemoteTransactionProvider.class, classLoader); final ArrayList<RemoteTransactionProvider> providers = new ArrayList<RemoteTransactionProvider>(); final Iterator<RemoteTransactionProvider> iterator = loader.iterator(); for (;;) try { if (! iterator.hasNext()) break; providers.add(iterator.next()); } catch (ServiceConfigurationError e) { Log.log.serviceConfigurationFailed(e); } providers.trimToSize(); return providers; }), false); }
private static List<StandardServiceInitiator> buildStandardServiceInitiatorList() { final ArrayList<StandardServiceInitiator> serviceInitiators = new ArrayList<StandardServiceInitiator>(); serviceInitiators.add( CfgXmlAccessServiceInitiator.INSTANCE ); serviceInitiators.add( ConfigurationServiceInitiator.INSTANCE ); serviceInitiators.add( PropertyAccessStrategyResolverInitiator.INSTANCE ); serviceInitiators.add( ImportSqlCommandExtractorInitiator.INSTANCE ); serviceInitiators.add( EntityCopyObserverFactoryInitiator.INSTANCE ); serviceInitiators.trimToSize();
List<LinkField> getList(String regex) { ArrayList<LinkField> list; if (Strings.isBlank(regex)) { list = lnks; } else { list = cache.get(regex); if (null == list) { synchronized (cache) { list = cache.get(regex); if (null == list) { list = new ArrayList<LinkField>(lnks.size()); for (LinkField lnk : lnks) if (Pattern.matches(regex, lnk.getName())) list.add(lnk); list.trimToSize(); cache.put(regex, list); } } } } return list; }
/** * Constructs a simple sequence from the passed collection model, which shouldn't be added to later. The internal * list will be build immediately (not lazily). The resulting sequence shouldn't be extended with * {@link #add(Object)}, because the appropriate {@link ObjectWrapper} won't be available; use * {@link #SimpleSequence(Collection, ObjectWrapper)} instead, if you need that. */ public SimpleSequence(TemplateCollectionModel tcm) throws TemplateModelException { ArrayList alist = new ArrayList(); for (TemplateModelIterator it = tcm.iterator(); it.hasNext(); ) { alist.add(it.next()); } alist.trimToSize(); list = alist; }
@Override public Collection<Unit> load(SootMethod m) throws Exception { ArrayList<Unit> res = new ArrayList<Unit>(); // only retain callers that are explicit call sites or // Thread.start() Iterator<Edge> edgeIter = new EdgeFilter().wrap(cg.edgesInto(m)); while (edgeIter.hasNext()) { Edge edge = edgeIter.next(); res.add(edge.srcUnit()); } res.trimToSize(); return res; } };
protected List<PoolConfiguration> getMatchingPoolConfigs(String poolName, ManagementRepository repository) { ArrayList<PoolConfiguration> result = new ArrayList<PoolConfiguration>(repository.getDataSources().size()); if (repository.getDataSources() != null) { for (DataSource ds : repository.getDataSources()) { if (poolName.equalsIgnoreCase(ds.getPool().getName())) { result.add(ds.getPoolConfiguration()); } } } result.trimToSize(); return result; }
final O item = iterator.next(); if (lastItem == null || !lastItem.equals(item)) { mergedList.add(item); mergedList.trimToSize(); return mergedList;
public List<Pool> match(String jndiName, ManagementRepository repository) { ArrayList<org.jboss.jca.core.api.connectionmanager.pool.Pool> result = new ArrayList<Pool>(repository .getDataSources().size()); if (repository.getDataSources() != null) { for (DataSource ds : repository.getDataSources()) { if (jndiName.equalsIgnoreCase(ds.getJndiName()) && ds.getPool() != null) { result.add(ds.getPool()); } } } result.trimToSize(); return result; } }
successors.add(nextUnit); successors.add(target); successors.trimToSize(); unitToSuccs.put(currentUnit, successors);
@Override public Collection<SootMethod> load(Unit u) throws Exception { ArrayList<SootMethod> res = null; // only retain callers that are explicit call sites or // Thread.start() Iterator<Edge> edgeIter = new EdgeFilter().wrap(cg.edgesOutOf(u)); while (edgeIter.hasNext()) { Edge edge = edgeIter.next(); SootMethod m = edge.getTgt().method(); if (includePhantomCallees || m.hasActiveBody()) { if (res == null) { res = new ArrayList<SootMethod>(); } res.add(m); } else if (IDESolver.DEBUG) { logger.error(String.format("Method %s is referenced but has no body!", m.getSignature(), new Exception())); } } if (res != null) { res.trimToSize(); return res; } else { return Collections.emptySet(); } } };
protected List<PoolConfiguration> getMatchingPoolConfigs(String poolName, ManagementRepository repository) { ArrayList<PoolConfiguration> result = new ArrayList<PoolConfiguration>(repository.getConnectors().size()); if (repository.getConnectors() != null) { for (Connector conn : repository.getConnectors()) { if (conn.getConnectionFactories() == null || conn.getConnectionFactories().get(0) == null || conn.getConnectionFactories().get(0).getPool() == null) continue; ConnectionFactory connectionFactory = conn.getConnectionFactories().get(0); if (poolName.equals(connectionFactory.getPool().getName())) { PoolConfiguration pc = conn.getConnectionFactories().get(0).getPoolConfiguration(); result.add(pc); } } } result.trimToSize(); return result; }
private List<ShapePoint> getUniqueShapePointsForShapeId(FeedScopedId shapeId) { List<ShapePoint> points = transitService.getShapePointsForShapeId(shapeId); ArrayList<ShapePoint> filtered = new ArrayList<ShapePoint>(points.size()); ShapePoint last = null; for (ShapePoint sp : points) { if (last == null || last.getSequence() != sp.getSequence()) { if (last != null && last.getLat() == sp.getLat() && last.getLon() == sp.getLon()) { LOG.trace("pair of identical shape points (skipping): {} {}", last, sp); } else { filtered.add(sp); } } last = sp; } if (filtered.size() != points.size()) { filtered.trimToSize(); return filtered; } else { return points; } }
keyCols.add(keyCol); else { for (String propName : type.fields().keySet()) { Column col = tbl.getColumn(propName); keyCols.add(tbl.indexColumn(col.getColumnId(), SortOrder.ASCENDING)); keyCols.add(keyCol); keyCols.add(affCol); else keyCols.trimToSize();
break; } else { routes.add(container.toString()); prevIP = container.mIP; routes.trimToSize(); mRoutes = routes;
attrs.add(pre); attrs.add(post); attrs.trimToSize();
private void decodeValueCollection(ASN1ValueCollection collection) throws IOException { int begOffset = offset; int endOffset = begOffset + length; ASN1Type type = collection.type; if (isVerify) { while (endOffset > offset) { next(); type.decode(this); } } else { int seqTagOffset = tagOffset; //store tag offset ArrayList<Object> values = new ArrayList<Object>(); while (endOffset > offset) { next(); values.add(type.decode(this)); } values.trimToSize(); content = values; tagOffset = seqTagOffset; //retrieve tag offset } if (offset != endOffset) { throw new ASN1Exception("Wrong encoding at [" + begOffset + "]. Content's length and encoded length are not the same"); } }