当前位置: 首页>>代码示例>>Java>>正文


Java IntArrayList.toArray方法代码示例

本文整理汇总了Java中com.carrotsearch.hppc.IntArrayList.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java IntArrayList.toArray方法的具体用法?Java IntArrayList.toArray怎么用?Java IntArrayList.toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.carrotsearch.hppc.IntArrayList的用法示例。


在下文中一共展示了IntArrayList.toArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readSparseVector

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private SparseVector readSparseVector (String str, Alphabet dict) throws IOException
{
  IntArrayList idxs = new IntArrayList ();
  DoubleArrayList vals = new DoubleArrayList ();
  String[] lines = str.split ("\n");
  for (int li = 0; li < lines.length; li++) {
    String line = lines[li];
    if (Pattern.matches ("^\\s*$", line)) continue;

    String[] fields = line.split ("\t");
    int idx;
    if (dict != null) {
      idx = dict.lookupIndex (fields[0]);
    } else {
      idx = Integer.parseInt (fields[0]);
    }

    double val = Double.parseDouble (fields[1]);
    idxs.add (idx);
    vals.add (val);
  }
  return new SparseVector (idxs.toArray (), vals.toArray ());
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:24,代码来源:ACRF.java

示例2: make3dMatrix

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private SparseMatrixn make3dMatrix ()
{
  int[] sizes = new int[]{2, 3, 4};
  IntArrayList idxs = new IntArrayList ();
  DoubleArrayList vals = new DoubleArrayList ();

  for (int i = 0; i < 24; i++) {
    if (i % 3 != 0) {
      idxs.add (i);
      vals.add (2.0 * i);
    }
  }

  SparseMatrixn a = new SparseMatrixn (sizes, idxs.toArray (), vals.toArray ());
  return a;
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:17,代码来源:TestSparseMatrixn.java

示例3: buildInterferenceGraph

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private Graph buildInterferenceGraph(List<Map<Instruction, BitSet>> liveInInformation, Program program) {
    GraphBuilder builder = new GraphBuilder(program.variableCount());
    for (Map<Instruction, BitSet> blockLiveIn : liveInInformation) {
        for (BitSet liveVarsSet : blockLiveIn.values()) {
            IntArrayList liveVars = new IntArrayList();
            for (int i = liveVarsSet.nextSetBit(0); i >= 0; i = liveVarsSet.nextSetBit(i + 1)) {
                liveVars.add(i);
            }
            int[] liveVarArray = liveVars.toArray();
            for (int i = 0; i < liveVarArray.length - 1; ++i) {
                for (int j = i + 1; j < liveVarArray.length; ++j) {
                    builder.addEdge(liveVarArray[i], liveVarArray[j]);
                    builder.addEdge(liveVarArray[j], liveVarArray[i]);
                }
            }
        }
    }
    return builder.build();
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:20,代码来源:GCShadowStackContributor.java

示例4: getSubsetInstance

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
/**
 * Returns a new data subset, only containing those rows that are included in the subset
 * @param rowset
 * @return
 */
protected DataSubset getSubsetInstance(RowSet rowset) {
    int index = -1;
    RowSet newset = RowSet.create(rowset.size());
    IntArrayList list = new IntArrayList();
    for (int row = 0; row < this.set.length(); row++) {
        if (rowset.contains(row)) {
            index++;
            if (this.set.contains(row)) {
                newset.add(index);
                list.add(index);
            }
        }
    }
    return new DataSubset(newset, list.toArray());
}
 
开发者ID:arx-deidentifier,项目名称:arx,代码行数:21,代码来源:DataSubset.java

示例5: retainMass

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public static TableFactor retainMass (DiscreteFactor ptl, double alpha)
{
  int[] idxs = new int [ptl.numLocations ()];
  double[] vals = new double [ptl.numLocations ()];
  for (int i = 0; i < idxs.length; i++) {
    idxs[i] = ptl.indexAtLocation (i);
    vals[i] = ptl.logValue (i);
  }

  RankedFeatureVector rfv = new RankedFeatureVector (new Alphabet(), idxs, vals);
  IntArrayList idxList = new IntArrayList ();
  DoubleArrayList valList = new DoubleArrayList ();

  double mass = Double.NEGATIVE_INFINITY;
  double logAlpha = Math.log (alpha);
  for (int rank = 0; rank < rfv.numLocations (); rank++) {
    int idx = rfv.getIndexAtRank (rank);
    double val = rfv.value (idx);
    mass = Maths.sumLogProb (mass, val);
    idxList.add (idx);
    valList.add (val);
    if (mass > logAlpha) {
      break;
    }
  }

  int[] szs = computeSizes (ptl);
  SparseMatrixn m = new SparseMatrixn (szs, idxList.toArray (), valList.toArray ());

  TableFactor result = new TableFactor (computeVars (ptl));
  result.setValues (m);

  return result;
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:35,代码来源:Factors.java

示例6: dumbSort

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private void dumbSort(IntArrayList arrayList) {
  int[] tmp = arrayList.toArray();
  Arrays.sort(tmp);
  arrayList.clear();
  for (int tmpval : tmp) {
    arrayList.add(tmpval);
  }
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:9,代码来源:ListVarSet.java

示例7: toValueArray

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private int[] toValueArray ()
{
  IntArrayList vals = new IntArrayList (maxTime () * numSlices ());
  for (int t = 0; t < lblseq.size (); t++) {
    Labels lbls = lblseq.getLabels (t);
    for (int j = 0; j < lbls.size (); j++) {
      Label lbl = lbls.get (j);
      vals.add (lbl.getIndex ());
    }
  }
  return vals.toArray();
}
 
开发者ID:cmoen,项目名称:mallet,代码行数:13,代码来源:LabelsAssignment.java

示例8: TypedFieldId

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public TypedFieldId(MajorType type, IntArrayList breadCrumb, PathSegment remainder) {
  this(type, type, type, false, remainder, breadCrumb.toArray());
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:4,代码来源:TypedFieldId.java

示例9: TypedFieldId

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public TypedFieldId(CompleteType type, IntArrayList breadCrumb, PathSegment remainder) {
  this(type, type, type, false, remainder, breadCrumb.toArray());
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:4,代码来源:TypedFieldId.java

示例10: main

import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public static void main (String[] args) throws IOException {
	CommandOption
								.setSummary(Text2Clusterings.class,
														"A tool to convert a list of text files to a Clusterings.");
	CommandOption.process(Text2Clusterings.class, args);

	if (classDirs.value.length == 0) {
		logger
					.warning("You must include --input DIR1 DIR2 ...' in order to specify a"
										+ "list of directories containing the documents for each class.");
		System.exit(-1);
	}

	Clustering[] clusterings = new Clustering[classDirs.value.length];
	int fi = 0;
	for (int i = 0; i < classDirs.value.length; i++) {
		Alphabet fieldAlph = new Alphabet();
		Alphabet valueAlph = new Alphabet();
		File directory = new File(classDirs.value[i]);
		File[] subdirs = getSubDirs(directory);
		Alphabet clusterAlph = new Alphabet();
		InstanceList instances = new InstanceList(new Noop());
		IntArrayList labels = new IntArrayList();
		for (int j = 0; j < subdirs.length; j++) {
			ArrayList<File> records = new FileIterator(subdirs[j]).getFileArray();
			int label = clusterAlph.lookupIndex(subdirs[j].toString());
			for (int k = 0; k < records.size(); k++) {
				if (fi % 100 == 0) System.out.print(fi);
				else if (fi % 10 == 0) System.out.print(".");
				if (fi % 1000 == 0 && fi > 0) System.out.println();
				System.out.flush();
				fi++;


				File record = records.get(k);
				labels.add(label);
				instances.add(new Instance(new Record(fieldAlph, valueAlph, parseFile(record)),
											new Integer(label), record.toString(),
											record.toString()));
			}
		}
		clusterings[i] =
				new Clustering(instances, subdirs.length, labels.toArray());
	}

	logger.info("\nread " + fi + " objects in " + clusterings.length + " clusterings.");
	try {
		ObjectOutputStream oos =
				new ObjectOutputStream(new FileOutputStream(outputFile.value));
		oos.writeObject(new Clusterings(clusterings));
		oos.close();
	} catch (Exception e) {
		logger.warning("Exception writing clustering to file " + outputFile.value
										+ " " + e);
		e.printStackTrace();
	}

}
 
开发者ID:cmoen,项目名称:mallet,代码行数:59,代码来源:Text2Clusterings.java


注:本文中的com.carrotsearch.hppc.IntArrayList.toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。