java.util.ArrayList#addAll ( )源码实例Demo

下面列出了java.util.ArrayList#addAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@SuppressWarnings("unchecked")
private String[] getStringValues(int n, String fieldName) throws IOException
{
    Document document = document(n);
    ArrayList<Field> fields = new ArrayList<Field>();
    ArrayList<String> answer = new ArrayList<String>(2);
    fields.addAll((List<Field>) document.getFields());

    for (Field field : fields)
    {
        if (field.name().equals(fieldName))
        {
            answer.add(field.stringValue());
        }
    }

    return answer.toArray(new String[answer.size()]);
}
 
源代码2 项目: CogniCrypt   文件: Answer.java
public Answer combineWith(final Answer a) {
	final Answer combined = new Answer();
	combined.setValue(this.value + " + " + a.getValue());

	final ArrayList<CodeDependency> cpD = new ArrayList<CodeDependency>();
	if (this.codeDependencies != null) {
		cpD.addAll(this.codeDependencies);
	}
	if (a.getCodeDependencies() != null) {
		cpD.addAll(a.getCodeDependencies());
	}
	combined.setCodeDependencies(cpD);

	final ArrayList<ClaferDependency> clD = new ArrayList<ClaferDependency>();
	if (this.claferDependencies != null) {
		clD.addAll(this.claferDependencies);
	}
	if (a.getClaferDependencies() != null) {
		clD.addAll(a.getClaferDependencies());
	}
	combined.setClaferDependencies(clD);

	return combined;
}
 
源代码3 项目: KEEL   文件: TreeNode.java
/**
 * Removes the descendants from a identifier given of a node. The nodes whose descendants are being
 * removed become leaf nodes
 * 
 * @param original_identifier   Identifier of the node that is becoming a leaf node and whose descendants
 * are being removed
 * @return ArrayList with all the identifiers of the nodes that are being removed
 */
public ArrayList <Integer> deleteDescendants (int original_identifier) {
    ArrayList <Integer> nodes_deleted;
    
    nodes_deleted = new ArrayList <Integer> ();
    
    // Obtain descendants of descendants
    if (left != null) {
        nodes_deleted.addAll(left.deleteDescendants(original_identifier));
    }
    
    if (right != null) {
        nodes_deleted.addAll(right.deleteDescendants(original_identifier));
    }
    
    left = null;
    right = null;
    condition = null;
    
    if (identifier != original_identifier) {
        nodes_deleted.add(identifier);
    }
    
    return nodes_deleted;
}
 
源代码4 项目: geoportal-server-harvester   文件: Client.java
private List<String> queryIdsScroll(String term, String value, long size) throws IOException, URISyntaxException {
  ArrayList<String> ids = new ArrayList<>();
  SearchContext searchContext = new SearchContext();

  while (!Thread.currentThread().isInterrupted()) {
    QueryResponse response = query(term, value, size, searchContext);
    if (Thread.currentThread().isInterrupted()) {
      break;
    }
    if (response.hits == null || response.hits.hits == null || response.hits.hits.isEmpty()) {
      break;
    }
    ids.addAll(response.hits.hits.stream()
            .map(h -> h._id)
            .filter(id -> id != null)
            .collect(Collectors.toList()));
  }

  return ids;
}
 
/**
 * @return Cache configurations.
 */
private CacheConfiguration[] getCacheConfigurations() {
    final ArrayList<CacheConfiguration> ccfgs = new ArrayList<>();

    ccfgs.add(getCacheConfiguration(OBJECT_CACHE));
    ccfgs.addAll(getCacheConfigurations(STR_CACHE, String.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(PRIM_CACHE, Integer.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(ENUM_CACHE, EnumKey.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(UUID_CACHE, UUID.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(DATE_CACHE, Date.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(TIMESTAMP_CACHE, Timestamp.class, Person.class));
    ccfgs.addAll(getCacheConfigurations(BIG_DECIMAL_CACHE, BigDecimal.class, Person.class));
    ccfgs.add(getCacheConfiguration(FIELD_CACHE, Integer.class, SearchValue.class));

    return ccfgs.toArray(new CacheConfiguration[ccfgs.size()]);
}
 
源代码6 项目: tuffylite   文件: DataMover.java
public double getMLEProb(Collection<GAtom> atoms, Set<Component> components, BitSet world){

		ArrayList<Partition> parts = new ArrayList<Partition>();
		for(Component c : components){
			parts.addAll(c.parts);
		}

		double rs = 0;

		for(Partition p : parts){

			BitSet conf = new BitSet(atoms.size()+1);
			for(Integer atom : p.mrf.getCoreAtoms()){
				if(p.mrf.atoms.get(atom).truth == true){
					conf.set(atom);
				}
			}

			rs += wordLogPF.get(p).get(conf);
		}

		rs -= wholeLogPF;

		return Math.exp(rs);
	}
 
源代码7 项目: openjdk-jdk9   文件: InvokableTypeImpl.java
/**
 * Shared implementation of {@linkplain ClassType#allMethods()} and
 * {@linkplain InterfaceType#allMethods()}
 * @return A list of all methods (recursively)
 */
public final List<Method> allMethods() {
    ArrayList<Method> list = new ArrayList<>(methods());
    ClassType clazz = superclass();
    while (clazz != null) {
        list.addAll(clazz.methods());
        clazz = clazz.superclass();
    }
    /*
     * Avoid duplicate checking on each method by iterating through
     * duplicate-free allInterfaces() rather than recursing
     */
    for (InterfaceType interfaze : getAllInterfaces()) {
        list.addAll(interfaze.methods());
    }
    return list;
}
 
源代码8 项目: baratine   文件: EnvLoader.java
/**
 * Starts the current environment.
 */
public static void stop(ClassLoader loader)
{
  for (; loader != null; loader = loader.getParent()) {
    if (loader instanceof EnvironmentClassLoader) {
      ((EnvironmentClassLoader) loader).stop();
      return;
    }
  }

  ArrayList<EnvLoaderListener> listeners;
  listeners = new ArrayList<EnvLoaderListener>();
  listeners.addAll(_globalEnvironmentListeners);
  _globalEnvironmentListeners.clear();

  for (int i = 0; i < listeners.size(); i++) {
    EnvLoaderListener listener = listeners.get(i);

    listener.environmentStop(null);
  }
}
 
源代码9 项目: Liz   文件: ViewUtil.java
public static List<View> getAllChildren(View target) {
    if (!(target instanceof ViewGroup)) return Collections.singletonList(target);

    ArrayList<View> allChildren = new ArrayList<>();
    ViewGroup viewGroup = (ViewGroup) target;
    for (int i = 0; i < viewGroup.getChildCount(); i++) {
        View child = viewGroup.getChildAt(i);
        ArrayList<View> targetsChildren = new ArrayList<>();
        targetsChildren.add(target);
        targetsChildren.addAll(getAllChildren(child));
        allChildren.addAll(targetsChildren);
    }
    return allChildren;
}
 
源代码10 项目: systemds   文件: ProgramConverter.java
/**
 * This creates a deep copy of a function program block. The central reference to singletons of function program blocks
 * poses the need for explicit copies in order to prevent conflicting writes of temporary variables (see ExternalFunctionProgramBlock.
 * 
 * @param namespace function namespace
 * @param oldName ?
 * @param pid ?
 * @param IDPrefix ?
 * @param prog runtime program
 * @param fnStack ?
 * @param fnCreated ?
 * @param plain ?
 */
public static void createDeepCopyFunctionProgramBlock(String namespace, String oldName, long pid, int IDPrefix, Program prog, HashSet<String> fnStack, HashSet<String> fnCreated, boolean plain) 
{
	//fpb guaranteed to be non-null (checked inside getFunctionProgramBlock)
	FunctionProgramBlock fpb = prog.getFunctionProgramBlock(namespace, oldName);
	String fnameNew = (plain)? oldName :(oldName+Lop.CP_CHILD_THREAD+pid); 
	String fnameNewKey = DMLProgram.constructFunctionKey(namespace,fnameNew);

	if( prog.getFunctionProgramBlocks().containsKey(fnameNewKey) )
		return; //prevent redundant deep copy if already existent
	
	//create deep copy
	FunctionProgramBlock copy = null;
	ArrayList<DataIdentifier> tmp1 = new ArrayList<>();
	ArrayList<DataIdentifier> tmp2 = new ArrayList<>();
	if( fpb.getInputParams()!= null )
		tmp1.addAll(fpb.getInputParams());
	if( fpb.getOutputParams()!= null )
		tmp2.addAll(fpb.getOutputParams());
	
	
	if( !fnStack.contains(fnameNewKey) ) {
		fnStack.add(fnameNewKey);
		copy = new FunctionProgramBlock(prog, tmp1, tmp2);
		copy.setChildBlocks( rcreateDeepCopyProgramBlocks(fpb.getChildBlocks(), pid, IDPrefix, fnStack, fnCreated, plain, fpb.isRecompileOnce()) );
		copy.setRecompileOnce( fpb.isRecompileOnce() );
		copy.setThreadID(pid);
		fnStack.remove(fnameNewKey);
	}
	else //stop deep copy for recursive function calls
		copy = fpb;
	
	//copy.setVariables( (LocalVariableMap) fpb.getVariables() ); //implicit cloning
	//note: instructions not used by function program block
	
	//put 
	prog.addFunctionProgramBlock(namespace, fnameNew, copy);
	fnCreated.add(DMLProgram.constructFunctionKey(namespace, fnameNew));
}
 
源代码11 项目: pacaya   文件: QFiles.java
private static List<File> getMatchingFiles(File file, Pattern regex) {
    ArrayList<File> files = new ArrayList<File>();
    if (file.exists()) {
        if (file.isFile()) {
            if (regex.matcher(file.getName()).matches()) {
                files.add(file);
            }
        } else {
            for (File subFile : file.listFiles()) {
                files.addAll(getMatchingFiles(subFile, regex));
            }
        }
    }
    return files;
}
 
源代码12 项目: Kylin   文件: AbstractHadoopJob.java
protected void attachKylinPropsAndMetadata(IIInstance ii, Configuration conf) throws IOException {
    File tmp = File.createTempFile("kylin_job_meta", "");
    tmp.delete(); // we need a directory, so delete the file first

    File metaDir = new File(tmp, "meta");
    metaDir.mkdirs();
    metaDir.getParentFile().deleteOnExit();

    // write kylin.properties
    KylinConfig kylinConfig = KylinConfig.getInstanceFromEnv();
    File kylinPropsFile = new File(metaDir, "kylin.properties");
    kylinConfig.writeProperties(kylinPropsFile);

    // write II / model_desc / II_desc / dict / table
    ArrayList<String> dumpList = new ArrayList<String>();
    dumpList.add(ii.getResourcePath());
    dumpList.add(ii.getDescriptor().getModel().getResourcePath());
    dumpList.add(ii.getDescriptor().getResourcePath());

    for (String tableName : ii.getDescriptor().getModel().getAllTables()) {
        TableDesc table = MetadataManager.getInstance(kylinConfig).getTableDesc(tableName);
        dumpList.add(table.getResourcePath());
    }

    for (IISegment segment : ii.getSegments()) {
        dumpList.addAll(segment.getDictionaryPaths());
    }

    dumpResources(kylinConfig, metaDir, dumpList);

    // hadoop distributed cache
    conf.set("tmpfiles", "file:///" + OptionsHelper.convertToFileURL(metaDir.getAbsolutePath()));
}
 
源代码13 项目: Open-Lowcode   文件: OrderedList.java
/**
 * gets an ordered list of all the elements
 * 
 * @return a full ordered list
 */
public ArrayList<E> getOrderedList() {
	ArrayList<E> orderedanswer = new ArrayList<E>();
	if (!orderedlist.isEmpty()) {
		Integer lastkey = orderedlist.lastKey();
		while (lastkey != null) {

			ArrayList<E> elements = orderedlist.get(lastkey);
			orderedanswer.addAll(elements);

			lastkey = orderedlist.lowerKey(lastkey);
		}
	}
	return orderedanswer;
}
 
源代码14 项目: jdk8u-jdk   文件: CPlatformWindow.java
private void orderAboveSiblingsImpl(Window[] windows) {
    ArrayList<Window> childWindows = new ArrayList<Window>();

    final ComponentAccessor componentAccessor = AWTAccessor.getComponentAccessor();
    final WindowAccessor windowAccessor = AWTAccessor.getWindowAccessor();

    // Go through the list of windows and perform ordering.
    for (Window w : windows) {
        boolean iconified = false;
        final Object p = componentAccessor.getPeer(w);
        if (p instanceof LWWindowPeer) {
            CPlatformWindow pw = (CPlatformWindow)((LWWindowPeer)p).getPlatformWindow();
            iconified = isIconified();
            if (pw != null && pw.isVisible() && !iconified) {
                // If the window is one of ancestors of 'main window' or is going to become main by itself,
                // the window should be ordered above its siblings; otherwise the window is just ordered
                // above its nearest parent.
                if (pw.isOneOfOwnersOrSelf(this)) {
                    CWrapper.NSWindow.orderFront(pw.getNSWindowPtr());
                } else {
                    CWrapper.NSWindow.orderWindow(pw.getNSWindowPtr(), CWrapper.NSWindow.NSWindowAbove,
                            pw.owner.getNSWindowPtr());
                }
                pw.applyWindowLevel(w);
            }
        }
        // Retrieve the child windows for each window from the list except iconified ones
        // and store them for future use.
        // Note: we collect data about child windows even for invisible owners, since they may have
        // visible children.
        if (!iconified) {
            childWindows.addAll(Arrays.asList(windowAccessor.getOwnedWindows(w)));
        }
    }
    // If some windows, which have just been ordered, have any child windows, let's start new iteration
    // and order these child windows.
    if (!childWindows.isEmpty()) {
        orderAboveSiblingsImpl(childWindows.toArray(new Window[0]));
    }
}
 
源代码15 项目: monasca-persister   文件: CassandraMetricBatch.java
public List<Deque<BatchStatement>> getAllBatches() {
  logTokenBatchMap("metric batches", metricQueries);
  logTokenBatchMap("dimension batches", dimensionQueries);
  logTokenBatchMap("dimension metric batches", dimensionMetricQueries);
  logTokenBatchMap("metric dimension batches", metricDimensionQueries);
  logReplicaBatchMap("measurement batches", measurementQueries);

  ArrayList<Deque<BatchStatement>> list = new ArrayList<>();
  list.addAll(metricQueries.values());
  list.addAll(dimensionQueries.values());
  list.addAll(dimensionMetricQueries.values());
  list.addAll(metricDimensionQueries.values());
  list.addAll(measurementQueries.values());
  return list;
}
 
源代码16 项目: Pydev   文件: JythonPlugin.java
/**
 * Executes all the scripts beneath some folders
 * @param beneathFolders the folders we want to get the scripts from
 * @return the errors that occured while executing the scripts
 */
public static List<Throwable> execAll(HashMap<String, Object> locals, final String startingWith,
        IPythonInterpreter interpreter, File[] beneathFolders, File[] additionalPythonpathFolders) {
    List<Throwable> errors = new ArrayList<Throwable>();

    ArrayList<File> pythonpath = new ArrayList<File>();
    pythonpath.addAll(Arrays.asList(beneathFolders));
    if (additionalPythonpathFolders != null) {
        pythonpath.addAll(Arrays.asList(additionalPythonpathFolders));
    }
    File[] pythonpathFolders = pythonpath.toArray(new File[pythonpath.size()]);

    for (File file : beneathFolders) {
        if (file != null) {
            if (!file.exists()) {
                String msg = "The folder:" + file +
                        " does not exist and therefore cannot be used to " +
                        "find scripts to run starting with:" + startingWith;
                Log.log(IStatus.ERROR, msg, null);
                errors.add(new RuntimeException(msg));
            }
            File[] files = getFilesBeneathFolder(startingWith, file);
            for (File f : files) {
                Throwable throwable = exec(locals, interpreter, f, pythonpathFolders);
                if (throwable != null) {
                    errors.add(throwable);
                }
            }
        }
    }
    return errors;
}
 
源代码17 项目: OSPREY3   文件: KAStarNode.java
private ArrayList<KAStarNode> getChildren( HashSet<ArrayList<String>> nextPLSeqs,
		HashSet<ArrayList<String>> pSeqs, HashSet<ArrayList<String>> lSeqs ) {

	ArrayList<ArrayList<String>> strandSeqs = new ArrayList<>(Arrays.asList(null, null, null));
	// lower bound pf values
	ArrayList<Boolean> lbContSCFlexVals = new ArrayList<>(Arrays.asList(false, false, true));
	ArrayList<String> lbPFImplVals = new ArrayList<>(Arrays.asList(new PFTraditional().getImpl(), new PFTraditional().getImpl(), new PFUB().getImpl()));

	// upper bound pf values
	ArrayList<Boolean> ubContSCFlexVals = new ArrayList<>(Arrays.asList(true, true, false));
	ArrayList<String> ubPFImplVals = new ArrayList<>(Arrays.asList(new PFUB().getImpl(), new PFUB().getImpl(), new PFTraditional().getImpl()));

	// minimized pf values
	ArrayList<Boolean> tightContSCFlexVals = new ArrayList<>(Arrays.asList(true, true, true));
	ArrayList<String> tightPFImplVals = new ArrayList<>(Arrays.asList(PFAbstract.getCFGImpl(), PFAbstract.getCFGImpl(), PFAbstract.getCFGImpl()));

	ArrayList<KAStarNode> ans = new ArrayList<>();

	for( ArrayList<String> pSeq : pSeqs ) {

		for( ArrayList<String> lSeq : lSeqs ) {

			ArrayList<String> putativeNextPLSeq = new ArrayList<String>();

			putativeNextPLSeq.addAll(pSeq);
			putativeNextPLSeq.addAll(lSeq);
			putativeNextPLSeq.trimToSize();

			if( !nextPLSeqs.contains(putativeNextPLSeq) ) continue;

			numCreated++;

			// create partition functions for next sequences
			strandSeqs.set(2, putativeNextPLSeq);
			strandSeqs.set(0, pSeq);
			strandSeqs.set(1, lSeq);

			if( !isFullyDefined() ) {
				// create partition functions
				ConcurrentHashMap<Integer, PFAbstract> lbPFs = ksObj.createPFs4Seqs(strandSeqs, lbContSCFlexVals, lbPFImplVals);
				ConcurrentHashMap<Integer, PFAbstract> ubPFs = ksObj.createPFs4Seqs(strandSeqs, ubContSCFlexVals, ubPFImplVals);

				// create KUStar node with lower and upper bounds
				ans.add( new KAStarNode( new KSCalc(numCreated, lbPFs), new KSCalc(numCreated, ubPFs), childScoreNeedsRefinement(lbPFs) ) );
				ans.get(ans.size()-1).parentlbScore = this.lbScore;
			}

			else if( KSImplKAStar.useTightBounds ) {
				// create a leaf node; we don't need upper or lower bounds ;we only need the minimized partition 
				// function our search problems exist, so we need only delete the lb, ub pfs from the table

				ConcurrentHashMap<Integer, PFAbstract> tightPFs = ksObj.createPFs4Seqs(strandSeqs, tightContSCFlexVals, tightPFImplVals);

				// assign sequence number from allowedSequences obj
				KSAllowedSeqs complexSeqs = ksObj.strand2AllowedSeqs.get(2);
				int seqID = complexSeqs.getPosOfSeq(tightPFs.get(2).getSequence());

				// create new KUStar node with tight score
				ans.add( new KAStarNode( new KSCalc(seqID, tightPFs), null, false ) );
				ans.get(ans.size()-1).parentlbScore = this.lbScore;

				// processed nodes are those whose confs will be minimized
				numLeavesCreated = ksObj.getNumSeqsCreated(1);
			}

			else
				throw new RuntimeException("ERROR: cannot expand a fully assigned node");
		}
	}

	return ans;
}
 
源代码18 项目: bitherj   文件: EnterpriseHDMTxSignaturePool.java
public List<Integer> signaturePubIndexes() {
    ArrayList<Integer> indexes = new ArrayList<Integer>();
    indexes.addAll(signatures.keySet());
    Collections.sort(indexes);
    return indexes;
}
 
源代码19 项目: birt   文件: HTMLLayoutPageHintManager.java
public ArrayList getPageHint( )
{
	ArrayList hints = new ArrayList( );
	hints.addAll( pageHints );
	return hints;
}
 
源代码20 项目: jdk8u_nashorn   文件: Compiler.java
private static <T> List<T> concat(final List<T> l1, final List<T> l2) {
    final ArrayList<T> l = new ArrayList<>(l1);
    l.addAll(l2);
    l.trimToSize();
    return l;
}