gnu.trove.TIntIterator Java Examples

The following examples show how to use gnu.trove.TIntIterator. 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: LinearBekGraphBuilder.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void collapse(LinearBekGraph graph) {
  for (int upNodeIndex : myTailEdges.keys()) {
    for (int downNodeIndex : myTailEdges.get(upNodeIndex)) {
      removeEdge(graph, upNodeIndex, downNodeIndex);
    }
  }

  TIntIterator it = myTails.iterator();
  while (it.hasNext()) {
    int tail = it.next();
    if (!LinearGraphUtils.getDownNodes(graph, tail).contains(myLeftChild)) {
      addEdge(graph, tail, myLeftChild);
    }
    else {
      replaceEdge(graph, tail, myLeftChild);
    }
  }
  removeEdge(graph, myParent, myLeftChild);
}
 
Example #2
Source File: UtilityBased.java    From jatecs with GNU General Public License v3.0 5 votes vote down vote up
public TIntDoubleHashMap getTable(double[][] utilities) {
    TIntDoubleHashMap rank = new TIntDoubleHashMap(
            (int) (testSize + testSize * 0.25), (float) 0.75);
    for (int docId = 0; docId < testSize; docId++) {
        double sum = 0.0;
        for (TIntIterator it = categoriesFilter.iterator(); it.hasNext(); ) {
            int catId = it.next();
            if (docCategoriesFilter[docId].contains(catId)) {
                sum += utilities[docId][catMap.get(catId)];
            }
        }
        rank.put(docId, sum);
    }
    return rank;
}
 
Example #3
Source File: LinearBekGraphBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public Set<Integer> getTailsAndBody() {
  Set<Integer> nodes = ContainerUtil.newHashSet();
  TIntIterator it = myBlockBody.iterator();
  while (it.hasNext()) {
    nodes.add(it.next());
  }
  it = myTails.iterator();
  while (it.hasNext()) {
    nodes.add(it.next());
  }
  return nodes;
}
 
Example #4
Source File: GraphicsMenuFactory.java    From whyline with MIT License 4 votes vote down vote up
public DataEntitySearchState() {
	
	GraphicalEventAppearance render = renderEvents.last();

	// Always skip the graphics context
	for(int arg = 1; arg < render.event.getNumberOfArgumentProducers(); arg++) {

		String name = render.event.getArgumentName(arg);
		Invoke invoke = (Invoke) trace.getInstruction(render.event.getEventID());
		QualifiedClassName argumentType = invoke.getMethodInvoked().getParsedDescriptor().getTypeOfArgumentNumber(arg - 1);
		if(argumentType == QualifiedClassName.INT)
			continue;

		Value value = trace.getOperandStackValue(render.event.getEventID(), arg);
		if(value.hasEventID()) {
					
			dependencies.add(value.getEventID());

			while(dependencies.size() > 0) {
			
				// Go through each dependency waiting to be analyzed and find its root dependencies.
				TIntIterator iterator = dependencies.iterator();
				while(iterator.hasNext()) {
					
					int eventID = iterator.next();

					Instruction inst = trace.getInstruction(eventID);
					
					visited.add(eventID);

					boolean isFieldUse = inst instanceof GETFIELD;
					QualifiedClassName fieldClassname = isFieldUse ? ((GETFIELD)inst).getFieldref().getClassname() : null;
					// HAAAAAAAAAAAACK!
					boolean isProjectClass = fieldClassname != null && !fieldClassname.getText().startsWith("java")  && !fieldClassname.getText().startsWith("sun");
					
					// Add operand stack dependencies if this isn't a field reference, or if it is, only if the field is part of the program (and not the SDK)
					if(!isFieldUse || isProjectClass) {
						for(Value vp : trace.getOperandStackDependencies(eventID))
							if(vp != null && vp.getEventID() >= 0)
								handleDependency(vp.getEventID());
					}
	
					int heapDependencyID = trace.getHeapDependency(eventID);
					if(heapDependencyID >= 0 && !visited.contains(heapDependencyID))
						handleDependency(heapDependencyID);
				
					IntegerVector objectDependencies = trace.getUnrecordedInvocationDependencyIDs(eventID);
					if(objectDependencies != null) {
						for(int i = 0; i < objectDependencies.size(); i++)
							handleDependency(objectDependencies.get(i));
					}
					
				}
				
				// Now that we've gone through these, make the new ones the next to iterate through and clear the new dependency set.
				TIntHashSet temp = newDependencies;
				dependencies.clear();
				newDependencies = dependencies;
				dependencies = temp;
				
			}
			
		}
					
	}			
	
}
 
Example #5
Source File: EmptyIntHashSet.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public TIntIterator iterator() {
  return EMPTY_INT_ITERATOR;
}