Java Code Examples for it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap#getInt()

The following examples show how to use it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap#getInt() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public boolean refines(int[][] lhsInvertedPlis, int[] rhs) {
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<IntArrayList> clustersMap = new Object2IntOpenHashMap<>(cluster.size());
		
		// Check if all subclusters of this cluster point into the same other clusters
		for (int recordId : cluster) {
			IntArrayList additionalLhsCluster = this.buildClusterIdentifier(recordId, lhsInvertedPlis);
			if (additionalLhsCluster == null)
				continue;
			
			if (clustersMap.containsKey(additionalLhsCluster)) {
				if ((rhs[recordId] == -1) || (clustersMap.getInt(additionalLhsCluster) != rhs[recordId]))
					return false;
			}
			else {
				clustersMap.put(additionalLhsCluster, rhs[recordId]);
			}
		}
	}
	return true;
}
 
Example 2
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public boolean refines(int[][] lhsInvertedPlis, int[] rhs) {
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<IntArrayList> clustersMap = new Object2IntOpenHashMap<>(cluster.size());
		
		// Check if all subclusters of this cluster point into the same other clusters
		for (int recordId : cluster) {
			IntArrayList additionalLhsCluster = this.buildClusterIdentifier(recordId, lhsInvertedPlis);
			if (additionalLhsCluster == null)
				continue;
			
			if (clustersMap.containsKey(additionalLhsCluster)) {
				if ((rhs[recordId] == -1) || (clustersMap.getInt(additionalLhsCluster) != rhs[recordId]))
					return false;
			}
			else {
				clustersMap.put(additionalLhsCluster, rhs[recordId]);
			}
		}
	}
	return true;
}
 
Example 3
Source File: PositionListIndex.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public boolean refines(int[][] lhsInvertedPlis, int[] rhs) {
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<IntArrayList> clustersMap = new Object2IntOpenHashMap<>(cluster.size());
		
		// Check if all subclusters of this cluster point into the same other clusters
		for (int recordId : cluster) {
			IntArrayList additionalLhsCluster = this.buildClusterIdentifier(recordId, lhsInvertedPlis);
			if (additionalLhsCluster == null)
				continue;
			
			if (clustersMap.containsKey(additionalLhsCluster)) {
				if ((rhs[recordId] == -1) || (clustersMap.getInt(additionalLhsCluster) != rhs[recordId]))
					return false;
			}
			else {
				clustersMap.put(additionalLhsCluster, rhs[recordId]);
			}
		}
	}
	return true;
}
 
Example 4
Source File: PositionListIndex.java    From winter with Apache License 2.0 6 votes vote down vote up
public boolean refines(int[][] lhsInvertedPlis, int[] rhs) {
	for (IntArrayList cluster : this.clusters) {
		Object2IntOpenHashMap<IntArrayList> clustersMap = new Object2IntOpenHashMap<>(cluster.size());
		
		// Check if all subclusters of this cluster point into the same other clusters
		for (int recordId : cluster) {
			IntArrayList additionalLhsCluster = this.buildClusterIdentifier(recordId, lhsInvertedPlis);
			if (additionalLhsCluster == null)
				continue;
			
			if (clustersMap.containsKey(additionalLhsCluster)) {
				if ((rhs[recordId] == -1) || (clustersMap.getInt(additionalLhsCluster) != rhs[recordId]))
					return false;
			}
			else {
				clustersMap.put(additionalLhsCluster, rhs[recordId]);
			}
		}
	}
	return true;
}
 
Example 5
Source File: MaterialListUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void updateAvailableCounts(List<MaterialListEntry> list, EntityPlayer player)
{
    Object2IntOpenHashMap<ItemType> playerInvItems = InventoryUtils.getInventoryItemCounts(player.inventory);

    for (MaterialListEntry entry : list)
    {
        ItemType type = new ItemType(entry.getStack(), false, true);
        int countAvailable = playerInvItems.getInt(type);
        entry.setCountAvailable(countAvailable);
    }
}
 
Example 6
Source File: HLA.java    From kourami with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public int processRecord(SAMRecord sr, Object2IntOpenHashMap<String> readLoadingSet){
int totalOp = 0;
String hlagene = HLA.extractHLAGeneName(sr.getReferenceName());
HLAGraph hg = this.hlaName2Graph.get(hlagene);
//hg.traverse();
if(hg != null){
    if(hg.isClassI()){
	boolean qc = this.qcCheck(sr);
	if(!qc)
	    return 0;
    }
    int readnum = readLoadingSet.getInt(sr.getReadName());
    //no such read has been read. return value of 0 means the hashSet doesn't have the read
    if(readnum == 0){
	readnum = sr.getFirstOfPairFlag() ? HLA.readNum : 0-HLA.readNum;
	
	readLoadingSet.put(sr.getReadName(), HLA.readNum);
	HLA.readNum++;
    }else
	readnum = sr.getFirstOfPairFlag() ? readnum : 0-readnum;

    totalOp += hg.addWeight(sr, readnum);//HLA.readNum);
    //HLA.readNum++;
}else{
    ;//HLA.log.appendln("UNKNOWN HLA GENE: " + hlagene);
}
return totalOp;
   }
 
Example 7
Source File: DistinctTable.java    From incubator-pinot with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor of the main DistinctTable which can be used to add records and merge other DistinctTables.
 */
public DistinctTable(DataSchema dataSchema, @Nullable List<OrderByExpressionContext> orderByExpressions, int limit) {
  _dataSchema = dataSchema;
  _limit = limit;

  // TODO: see if 10k is the right max initial capacity to use
  // NOTE: When LIMIT is smaller than or equal to the MAX_INITIAL_CAPACITY, no resize is required.
  int initialCapacity = Math.min(limit, MAX_INITIAL_CAPACITY);
  _uniqueRecords = new ObjectOpenHashSet<>(initialCapacity);
  if (orderByExpressions != null) {
    String[] columns = dataSchema.getColumnNames();
    int numColumns = columns.length;
    Object2IntOpenHashMap<String> columnIndexMap = new Object2IntOpenHashMap<>(numColumns);
    for (int i = 0; i < numColumns; i++) {
      columnIndexMap.put(columns[i], i);
    }
    int numOrderByColumns = orderByExpressions.size();
    int[] orderByColumnIndexes = new int[numOrderByColumns];
    boolean[] orderByAsc = new boolean[numOrderByColumns];
    for (int i = 0; i < numOrderByColumns; i++) {
      OrderByExpressionContext orderByExpression = orderByExpressions.get(i);
      orderByColumnIndexes[i] = columnIndexMap.getInt(orderByExpression.getExpression().toString());
      orderByAsc[i] = orderByExpression.isAsc();
    }
    _sortedRecords = new PriorityQueue<>(initialCapacity, (record1, record2) -> {
      Object[] values1 = record1.getValues();
      Object[] values2 = record2.getValues();
      for (int i = 0; i < numOrderByColumns; i++) {
        Comparable valueToCompare1 = (Comparable) values1[orderByColumnIndexes[i]];
        Comparable valueToCompare2 = (Comparable) values2[orderByColumnIndexes[i]];
        int result =
            orderByAsc[i] ? valueToCompare2.compareTo(valueToCompare1) : valueToCompare1.compareTo(valueToCompare2);
        if (result != 0) {
          return result;
        }
      }
      return 0;
    });
  } else {
    _sortedRecords = null;
  }
  _records = null;
}
 
Example 8
Source File: IntegerFunctions.java    From symja_android_library with GNU General Public License v3.0 4 votes vote down vote up
@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
	IExpr result = F.NIL;
	int radix = 10;
	if (ast.isAST1()) {
		result = F.IntegerDigits.of(engine, ast.arg1());
	} else if (ast.size() >= 3) {
		radix = ast.arg2().toIntDefault();
		if (radix <= 0) {
			return F.NIL;
		}
		result = F.IntegerDigits.of(engine, ast.arg1(), ast.arg2());
	}
	if (result.isList()) {
		IAST list = (IAST) result;

		Object2IntOpenHashMap<IExpr> map = new Object2IntOpenHashMap<IExpr>();
		for (int i = 1; i < list.size(); i++) {
			map.addTo((IExpr) list.get(i), 1);
		}
		if (ast.isAST3()) {
			int index = ast.arg3().toIntDefault();
			if (index > 0 && index < radix) {
				int count = map.getInt(F.ZZ(index));
				return F.ZZ(count);
			}
			return F.NIL;
		}
		
		if (Config.MAX_AST_SIZE < radix  ) {
			ASTElementLimitExceeded.throwIt(radix);
		}
		IExpr[] arr = new IExpr[radix];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = F.C0;
		}
		for (Object2IntMap.Entry<IExpr> element : map.object2IntEntrySet()) {
			IExpr key = element.getKey();
			int k = key.toIntDefault();
			if (k == 0) {
				arr[radix - 1] = F.ZZ(element.getIntValue());
			} else if (k > 0 && k < radix) {
				arr[k - 1] = F.ZZ(element.getIntValue());
			} else {
				return F.NIL;
			}
		}
		return F.ast(arr, F.List);

	}
	return F.NIL;
}