本文整理匯總了Java中it.unimi.dsi.fastutil.ints.IntArrayList.add方法的典型用法代碼示例。如果您正苦於以下問題:Java IntArrayList.add方法的具體用法?Java IntArrayList.add怎麽用?Java IntArrayList.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類it.unimi.dsi.fastutil.ints.IntArrayList
的用法示例。
在下文中一共展示了IntArrayList.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filter
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
@Override public TFloatVector filter(float x) {
IntArrayList nonzeroIndex = new IntArrayList();
int nonzero = 0;
for (int i = 0; i < values.length; i++) {
if (Math.abs(values[i]) > x) {
nonzero++;
nonzeroIndex.add(i);
}
}
if (nonzero < values.length * 0.5) {
LOG.debug(String.format("Dense Row filter generate a sparse row with nonzero %d", nonzero));
int[] newIndex = new int[nonzero];
System.arraycopy(nonzeroIndex.elements(), 0, newIndex, 0, nonzero);
float[] newValue = new float[nonzero];
for (int i = 0; i < nonzero; i++) {
newValue[i] = values[newIndex[i]];
}
SparseFloatVector ret = new SparseFloatVector(dim, newIndex, newValue);
ret.setRowId(rowId).setMatrixId(matrixId).setClock(clock);
return ret;
} else {
return this;
}
}
示例2: getChainedNouns
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
/**
* Given a sequence of words and a pivot-word index, return the chained nouns from the left and from the right
* of the pivot word.
* @param sequence: a sequence of words (list of IndexedWord)
* @param wordInd: the index of the pivot word
* @return a list of chained nouns to the left and the right of the pivot word (the pivot word is included)
*/
public static ObjectArrayList<IndexedWord> getChainedNouns(ObjectArrayList<IndexedWord> sequence, int wordInd){
IntArrayList chainedNounsInd = new IntArrayList();
// Get the chained nouns from left and right
IntArrayList chainedNounsLeft = getChainedNounsFromLeft(sequence, chainedNounsInd.clone(), wordInd);
IntArrayList chainedNounsRight = getChainedNounsFromRight(sequence, chainedNounsInd.clone(), wordInd);
// Add all the words to the chained nouns
chainedNounsInd.addAll(chainedNounsLeft);
chainedNounsInd.add(wordInd);
chainedNounsInd.addAll(chainedNounsRight);
// IndexedWord chained nouns
ObjectArrayList<IndexedWord> iChainedNouns = new ObjectArrayList<IndexedWord>();
for (int i: FastUtil.sort(chainedNounsInd)){
iChainedNouns.add(sequence.get(i));
}
return iChainedNouns;
}
示例3: contaminationDownsampling
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
public void contaminationDownsampling(final Map<String, Double> perSampleDownsamplingFraction) {
final int sampleCount = samples.sampleCount();
final IntArrayList readsToRemove = new IntArrayList(10); // blind estimate, can be improved?
final int alleleCount = alleles.alleleCount();
for (int s = 0; s < sampleCount; s++) {
final String sample = samples.sampleAt(s);
final Double fractionDouble = perSampleDownsamplingFraction.get(sample);
if (fractionDouble == null)
continue;
final double fraction = fractionDouble;
if (Double.isNaN(fraction) || fraction <= 0.0)
continue;
if (fraction >= 1.0) {
final int sampleReadCount = readsBySampleIndex[s].length;
readsToRemove.ensureCapacity(sampleReadCount);
for (int r = 0; r < sampleReadCount; r++)
readsToRemove.add(r);
removeSampleReads(s, readsToRemove, alleleCount);
readsToRemove.clear();
} else {
final Map<A, List<GATKSAMRecord>> readsByBestAllelesMap = readsByBestAlleleMap(s);
removeSampleReads(s, AlleleBiasedDownsamplingUtils.selectAlleleBiasedReads(readsByBestAllelesMap, fraction), alleleCount);
}
}
}
示例4: getListsCombinationIndices
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
/**
* Given a list of lists, return all the combinations between the lists (i.e. their indices). For example, suppose we
* have the list of lists: [[1, 2, 3], [4, 5], [6, 7, 8]]. Then, this function will return:
* [[0, 1], [1, 0], [0, 2], [2, 0], [1, 2], [2, 1],
* [0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 1, 0], [2, 0, 1]]
* @param lists: list of lists
* @return
*/
public static <T> ObjectArrayList<IntArrayList> getListsCombinationIndices(ObjectArrayList<ObjectArrayList<T>> lists){
ObjectArrayList<IntArrayList> combinationsInd = new ObjectArrayList<>();
ObjectArrayList<IntArrayList> result = new ObjectArrayList<>();
int[][] combinations;
for (int k = 2; k <= lists.size(); k++){
result.clear();
combinations = null;
combinations = getCombinations(k, lists.size());
for (int i = 0; i < combinations.length; i++) {
IntArrayList indices = new IntArrayList();
for (int j = 0; j < combinations[i].length; j++) {
indices.add(combinations[i][j]);
}
permute(indices, 0, result);
}
combinationsInd.addAll(result);
}
return combinationsInd;
}
示例5: getChainedTagNoNER
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
/**
* Given a sequence of words and a pivot-word index, return the "chained words" from the left and from the right
* of the pivot word. "Chained words" are a list of words, which all of them share the same POS tag and have no
* NE types.
*
* @param sequence: a sequence of words (list of IndexedWord)
* @param wordInd: the index of the pivot word
* @return a list of chained words to the left and the right of the pivot word (the pivot word is included)
*/
public static ObjectArrayList<IndexedWord> getChainedTagNoNER(ObjectArrayList<IndexedWord> sequence, int wordInd){
IntArrayList chainedPosWordsInd = new IntArrayList();
// Get the chained nouns from left and right
IntArrayList chainedPosWordsLeft = getChainedTagsFromLeftNoNER(sequence, chainedPosWordsInd.clone(), wordInd);
IntArrayList chainedPosWordsRight = getChainedTagsFromRightNoNER(sequence, chainedPosWordsInd.clone(), wordInd);
// Add all the words to the chained nouns
chainedPosWordsInd.addAll(chainedPosWordsLeft);
chainedPosWordsInd.add(wordInd);
chainedPosWordsInd.addAll(chainedPosWordsRight);
// IndexedWord chained nouns
ObjectArrayList<IndexedWord> iChainedNouns = new ObjectArrayList<IndexedWord>();
for (int i: FastUtil.sort(chainedPosWordsInd)){
iChainedNouns.add(sequence.get(i));
}
return iChainedNouns;
}
示例6: listOfWordsToIndexList
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
/**
* Given a list of indexed words 'words', return an integer list of indices of the words
* @param words: list of indexed words
* @return list of indices of the words
*/
public static IntArrayList listOfWordsToIndexList(ObjectArrayList<IndexedWord> words){
IntArrayList indices = new IntArrayList();
for (IndexedWord word: words){
indices.add(word.index());
}
return indices;
}
示例7: filter
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
@Override
public TIntDoubleVector filter(double x) {
IntArrayList nonzeroIndex = new IntArrayList();
int nonzero = 0;
for (int i = 0; i < values.length; i++) {
if (Math.abs(values[i]) > x) {
nonzero++;
nonzeroIndex.add(i);
}
}
if (nonzero < values.length * 0.5) {
LOG.debug(String.format("Dense Row filter generate a sparse row with nonzero %d", nonzero));
int[] newIndex = new int[nonzero];
System.arraycopy(nonzeroIndex.elements(), 0, newIndex, 0, nonzero);
double[] newValue = new double[nonzero];
for (int i = 0; i < nonzero; i++) {
newValue[i] = values[newIndex[i]];
}
SparseDoubleSortedVector ret = new SparseDoubleSortedVector(dim, newIndex, newValue);
ret.setRowId(rowId).setMatrixId(matrixId).setClock(clock);
return ret;
} else {
return this;
}
}
示例8: filterToOnlyOverlappingUnclippedReads
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
/**
* Remove those reads that do not overlap certain genomic location.
* <p>
* <p>
* This method modifies the current read-likelihoods collection.
* </p>
*
* @param location the target location.
* @throws IllegalArgumentException the location cannot be {@code null} nor unmapped.
*/
@SuppressWarnings("unused")
public void filterToOnlyOverlappingUnclippedReads(final GenomeLoc location) {
if (location == null)
throw new IllegalArgumentException("the location cannot be null");
if (location.isUnmapped())
throw new IllegalArgumentException("the location cannot be unmapped");
final int sampleCount = samples.sampleCount();
final int locContig = location.getContigIndex();
final int locStart = location.getStart();
final int locEnd = location.getStop();
final int alleleCount = alleles.alleleCount();
final IntArrayList removeIndices = new IntArrayList(10);
for (int s = 0; s < sampleCount; s++) {
int readRemoveCount = 0;
final GATKSAMRecord[] sampleReads = readsBySampleIndex[s];
final int sampleReadCount = sampleReads.length;
for (int r = 0; r < sampleReadCount; r++)
if (!unclippedReadOverlapsRegion(sampleReads[r], locContig, locStart, locEnd))
removeIndices.add(r);
removeSampleReads(s, removeIndices, alleleCount);
removeIndices.clear();
}
}
示例9: calculateClusterMapsStatic
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
protected static List<HashMap<String, IntArrayList>> calculateClusterMapsStatic(ObjectArrayList<List<String>> records, int numAttributes) throws InputIterationException {
List<HashMap<String, IntArrayList>> clusterMaps = new ArrayList<>();
for (int i = 0; i < numAttributes; i++)
clusterMaps.add(new HashMap<String, IntArrayList>());
int recordId = 0;
for (List<String> record : records) {
int attributeId = 0;
for (String value : record) {
HashMap<String, IntArrayList> clusterMap = clusterMaps.get(attributeId);
if (clusterMap.containsKey(value)) {
clusterMap.get(value).add(recordId);
}
else {
IntArrayList newCluster = new IntArrayList();
newCluster.add(recordId);
clusterMap.put(value, newCluster);
}
attributeId++;
}
recordId++;
}
return clusterMaps;
}
示例10: buildClusterIdentifier
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
protected IntArrayList buildClusterIdentifier(int recordId, int[][] lhsInvertedPlis) {
IntArrayList clusterIdentifier = new IntArrayList(lhsInvertedPlis.length);
for (int attributeIndex = 0; attributeIndex < lhsInvertedPlis.length; attributeIndex++) {
int clusterId = lhsInvertedPlis[attributeIndex][recordId];
if (clusterId < 0)
return null;
clusterIdentifier.add(clusterId);
}
return clusterIdentifier;
}
示例11: calculateClusterMaps
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
protected List<HashMap<String, IntArrayList>> calculateClusterMaps(RelationalInput relationalInput, int numAttributes) throws InputIterationException {
List<HashMap<String, IntArrayList>> clusterMaps = new ArrayList<>();
for (int i = 0; i < numAttributes; i++)
clusterMaps.add(new HashMap<String, IntArrayList>());
this.numRecords = 0;
while (relationalInput.hasNext() && (this.inputRowLimit <= 0 || this.inputRowLimit != this.numRecords)) {
List<String> record = relationalInput.next();
int attributeId = 0;
for (String value : record) {
HashMap<String, IntArrayList> clusterMap = clusterMaps.get(attributeId);
if (clusterMap.containsKey(value)) {
clusterMap.get(value).add(this.numRecords);
}
else {
IntArrayList newCluster = new IntArrayList();
newCluster.add(this.numRecords);
clusterMap.put(value, newCluster);
}
attributeId++;
}
this.numRecords++;
if (this.numRecords == Integer.MAX_VALUE - 1)
throw new RuntimeException("PLI encoding into integer based PLIs is not possible, because the number of records in the dataset exceeds Integer.MAX_VALUE. Use long based plis instead! (NumRecords = " + this.numRecords + " and Integer.MAX_VALUE = " + Integer.MAX_VALUE);
}
return clusterMaps;
}
示例12: getChainedTagsFromLeftNoNER
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
/**
* Given a sequence of indexed words and a pivot, get all the words 'chained' to the word from the left (i.e. having
* the same POS tag as the pivot word). Also, the chained words should not have NE types.
*
* @param sequence: a list of words
* @param wordInd: the word index from where the search starts
* @return a list of words which precede 'word'
*/
private static IntArrayList getChainedTagsFromLeftNoNER(ObjectArrayList<IndexedWord> sequence,
IntArrayList chainedPosWords, int wordInd){
// If the word is the leftiest word or it's not with the same POS tag - return
if (wordInd > 0 && sequence.get(wordInd).tag().equals(sequence.get(wordInd-1).tag()) &&
sequence.get(wordInd-1).ner().equals(NE_TYPE.NO_NER)){
chainedPosWords.add(wordInd-1);
getChainedTagsFromLeftNoNER(sequence, chainedPosWords, wordInd-1);
}
return chainedPosWords;
}
示例13: intersect
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
public PositionListIndex intersect(int[]... plis) {
List<IntArrayList> clusters = new ArrayList<>();
for (IntArrayList pivotCluster : this.clusters) {
HashMap<IntArrayList, IntArrayList> clustersMap = new HashMap<IntArrayList, IntArrayList>(pivotCluster.size());
for (int recordId : pivotCluster) {
IntArrayList subClusters = new IntArrayList(plis.length);
boolean isUnique = false;
for (int i = 0; i < plis.length; i++) {
if (plis[i][recordId] == -1) {
isUnique = true;
break;
}
subClusters.add(plis[i][recordId]);
}
if (isUnique)
continue;
if (!clustersMap.containsKey(subClusters))
clustersMap.put(subClusters, new IntArrayList());
clustersMap.get(subClusters).add(recordId);
}
for (IntArrayList cluster : clustersMap.values())
if (cluster.size() > 1)
clusters.add(cluster);
}
return new PositionListIndex(-1, clusters);
}
示例14: getChainedNERsFromLeft
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
/**
* Given a sequence of indexed words and a NER word, get all the NERs 'chained' to the word from the left (they all
* must have the same NER).
* @param sequence: a list of words
* @param wordInd: the word index from where the search starts (the pivot word)
* @param ner: the NE type of the pivot word
* @return a list of nouns which preced 'word'
*/
private static IntArrayList getChainedNERsFromLeft(ObjectArrayList<IndexedWord> sequence,
IntArrayList chainedNERs, int wordInd, String ner){
// If the word is the leftiest word or it's not a noun - return
if (wordInd > 0 && sequence.get(wordInd-1).ner().equals(ner)){
chainedNERs.add(wordInd-1);
getChainedNERsFromLeft(sequence, chainedNERs, wordInd-1, ner);
}
return chainedNERs;
}
示例15: buildAllColumnTextAndIndexes
import it.unimi.dsi.fastutil.ints.IntArrayList; //導入方法依賴的package包/類
private void buildAllColumnTextAndIndexes(RankedItem<T> listItem, IntArrayList indexesOfColumnBreaks, StringBuilder allColumnText) {
for (int index = 0; index < fields.size(); index++) {
FieldResolver<T> column = fields.get(index);
String columnContent = column.fieldResolver.apply(listItem.dataItem);
allColumnText.append(columnContent);
if (index < fields.size() - 1) allColumnText.append(" ");
indexesOfColumnBreaks.add(allColumnText.length() - 1);
}
}