本文整理汇总了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 ());
}
示例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;
}
示例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();
}
示例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());
}
示例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;
}
示例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);
}
}
示例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();
}
示例8: TypedFieldId
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public TypedFieldId(MajorType type, IntArrayList breadCrumb, PathSegment remainder) {
this(type, type, type, false, remainder, breadCrumb.toArray());
}
示例9: TypedFieldId
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
public TypedFieldId(CompleteType type, IntArrayList breadCrumb, PathSegment remainder) {
this(type, type, type, false, remainder, breadCrumb.toArray());
}
示例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();
}
}