Java Code Examples for gnu.trove.iterator.TIntIterator#hasNext()

The following examples show how to use gnu.trove.iterator.TIntIterator#hasNext() . 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: Jaccard.java    From ADW with GNU General Public License v3.0 6 votes vote down vote up
public double compare(
		TIntFloatMap v1,
		TIntFloatMap v2,
		boolean sorted) 
{
           int overlaps = 0;
	
           TIntIterator iter = v1.keySet().iterator();
           while (iter.hasNext())
           {
               int key = iter.next();
               if (v2.containsKey(key))
                   overlaps++;
           }
           
           return overlaps / (double)(v1.size() + v2.size() - overlaps);
}
 
Example 2
Source File: ClusterPair.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public boolean fullCheck(List<Predicate> p, Consumer<ClusterPair> consumer) {
	TIntIterator iter = c1.iterator();
	while (iter.hasNext()) {
		int line1 = iter.next();
		Cluster newC = new Cluster();

		TIntIterator iter2 = c2.iterator();
		while (iter2.hasNext()) {
			int line2 = iter2.next();
			if (line1 != line2 && p.stream().allMatch(pr -> pr.satisfies(line1, line2))) {
				newC.add(line2);
			}
		}
		ClusterPair newPair = new ClusterPair(new Cluster(line1), newC);
		if (newPair.containsLinePair())
			consumer.accept(newPair);
	}

	return true;
}
 
Example 3
Source File: ClusterPair.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public boolean fullCheck(List<Predicate> p, Collection<ClusterPair> newClusters) {
	TIntIterator iter = c1.iterator();
	while (iter.hasNext()) {
		int line1 = iter.next();
		Cluster newC = new Cluster();

		TIntIterator iter2 = c2.iterator();
		while (iter2.hasNext()) {
			int line2 = iter2.next();
			if (line1 != line2 && p.stream().allMatch(pr -> pr.satisfies(line1, line2))) {
				newC.add(line2);
			}
		}
		ClusterPair newPair = new ClusterPair(new Cluster(line1), newC);
		if (newPair.containsLinePair())
			newClusters.add(newPair);
	}

	return true;
}
 
Example 4
Source File: ClusterPair.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
private void filter(Predicate p, int index, Consumer<ClusterPair> consumer) {
	Cluster c = index == 0 ? c1 : c2;
	boolean didRefine = false;
	Cluster newC = new Cluster();

	TIntIterator iter = c.iterator();
	while (iter.hasNext()) {
		int line = iter.next();
		if (p.satisfies(line, line))
			newC.add(line);
		else
			didRefine = true;

	}

	if (didRefine) {
		ClusterPair newPair = index == 0 ? new ClusterPair(newC, c2) : new ClusterPair(c1, newC);

		if (newPair.containsLinePair())
			consumer.accept(newPair);
	} else {
		newC = null;
		consumer.accept(this);
	}
}
 
Example 5
Source File: Cluster.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public static Cluster minus(Cluster c1, Cluster cNot) {
	if (cNot.size() < 1)
		return c1;

	TIntHashSet set = new TIntHashSet(cNot.array);

	Cluster cNew2 = new Cluster();
	TIntIterator iterOld = c1.iterator();
	while (iterOld.hasNext()) {
		int nextOld = iterOld.next();
		if (!set.contains(nextOld)) {
			cNew2.add(nextOld);
		}
	}
	return cNew2;
}
 
Example 6
Source File: EntityCSVReader.java    From JedAIToolkit with Apache License 2.0 6 votes vote down vote up
@Override
public String getMethodConfiguration() {
    final StringBuilder sb = new StringBuilder();
    sb.append("{");
    final TIntIterator iterator = attributesToExclude.iterator();
    while (iterator.hasNext()) {
        int attributeId = iterator.next();
        sb.append(attributeId).append(",");
    }
    sb.append("}");

    return getParameterName(0) + "=" + inputFilePath + "\t"
            + getParameterName(1) + "=" + attributeNamesInFirstRow + "\t"
            + getParameterName(2) + "=" + separator + "\t"
            + getParameterName(3) + "=" + idIndex + "\t"
            + getParameterName(4) + "=" + sb.toString();
}
 
Example 7
Source File: InitialAlgebra.java    From CQL with GNU Affero General Public License v3.0 6 votes vote down vote up
private boolean saturate1() {
	boolean changed = false;
	for (Gen gen : col.gens().keySet()) {
		En en = col.gens().get(gen);
		Term<Void, En, Void, Fk, Void, Gen, Void> xx = Term.Gen(gen);
		changed = changed | add(en, xx);
	}
	for (Fk fk : col.fks().keySet()) {
		Pair<En, En> e = schema().fks.get(fk);
		TIntIterator it = ens.get(e.first).iterator();
		while (it.hasNext()) {
			int x = it.next();
			changed = changed | add(e.second, Term.Fk(fk, repr(e.first, x)));
		}
	}
	return changed;
}
 
Example 8
Source File: SpatialDetector.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
public List<BlockPos> getBlockPosArrayList() {
    List<BlockPos> detectedBlockPos = new ArrayList<BlockPos>(foundSet.size());
    TIntIterator intIter = foundSet.iterator();
    while (intIter.hasNext()) {
        int hash = intIter.next();
        BlockPos fromHash = getPosWithRespectTo(hash, firstBlock);
        if (fromHash.getY() + 128 - firstBlock.getY() < 0) {
            System.err.println("I really hope this doesnt happen");
            return new ArrayList<BlockPos>();
        }
        detectedBlockPos.add(fromHash);
    }
    return detectedBlockPos;
}
 
Example 9
Source File: ProcessLinkSearchMap.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private List<ProcessLink> getLinks(TIntIterator iterator) {
	List<ProcessLink> links = new ArrayList<>();
	while (iterator.hasNext()) {
		ProcessLink next = data.get(iterator.next());
		if (next != null)
			links.add(next);
	}
	return links;
}
 
Example 10
Source File: Region.java    From vethrfolnir-mu with GNU General Public License v3.0 5 votes vote down vote up
public void broadcastToKnown(GameObject broadcaster, WritePacket packet, Object... params) {
	KnownCreatures knownCreatures = broadcaster.get(PlayerMapping.KnownCreatures);
	TIntIterator iter = knownCreatures.knownIds.iterator();
	
	while(iter.hasNext()) {
		int id = iter.next();
		
		GameObject entity = entityWorld.getEntitys().get(id);
		entity.sendPacket(packet, params);
	}
}
 
Example 11
Source File: WordCluster.java    From fnlp with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * merge clusters
 */
public void mergeCluster() {
	int maxc1 = -1;
	int maxc2 = -1;
	float maxL = Float.NEGATIVE_INFINITY;
	TIntIterator it1 = slots.iterator();		
	while(it1.hasNext()){
		int i = it1.next();
		TIntIterator it2 = slots.iterator();
		//			System.out.print(i+": ");
		while(it2.hasNext()){
			int j= it2.next();

			if(i>=j)
				continue;
			//				System.out.print(j+" ");
			float L = calcL(i, j);
			//				System.out.print(L+" ");
			if (L > maxL) {
				maxL = L;
				maxc1 = i;
				maxc2 = j;
			}
		}
		//			System.out.println();
	}
	//		if(maxL == Float.NEGATIVE_INFINITY )
	//			return;

	merge(maxc1,maxc2);
}
 
Example 12
Source File: WordClusterM.java    From fnlp with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
	 * merge clusters
	 */
	public void mergeCluster() {
		maxc1 = -1;
		maxc2 = -1;
		maxL = Float.NEGATIVE_INFINITY;
		TIntIterator it1 = slots.iterator();
		
		while(it1.hasNext()){
			int i = it1.next();
			TIntIterator it2 = slots.iterator();
//			System.out.print(i+": ");
			while(it2.hasNext()){
				int j= it2.next();
				
				if(i>=j)
					continue;
//				System.out.print(j+" ");
				Multiplesolve c = new Multiplesolve(i,j);
				count.incrementAndGet();
				pool.execute(c);				
			}
//			System.out.println();
		}
		
			while(count.get()!=0){//等待所有子线程执行完  
				try {
					Thread.sleep(slotsize*slotsize/1000);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}  
			}  

		merge(maxc1,maxc2);
	}
 
Example 13
Source File: BinarySparseVector.java    From fnlp with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public float dotProduct(HashSparseVector sv) {
	float v =0f;
	TIntIterator it = data.iterator();			
	while(it.hasNext()){
		int i = it.next();
		v += sv.get(i);
	}
	return v;
}
 
Example 14
Source File: BinarySparseVector.java    From fnlp with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public float dotProduct(float[] vector) {
	TIntIterator it = data.iterator();
	float sum = 0f;
	while(it.hasNext()){
		int i = it.next();
		if(i<0||i>=vector.length)
			continue;
		sum += vector[i];
	}
	return sum;
}
 
Example 15
Source File: DynamicGrid.java    From cineast with MIT License 5 votes vote down vote up
@Override
public Set<Position> getKeySet() {
  HashSet<Position> _return = new HashSet<>();
  TIntIterator xiter = grid.keySet().iterator();
  while(xiter.hasNext()){
    int x = xiter.next();
    TIntIterator yiter = grid.get(x).keySet().iterator();
    while(yiter.hasNext()){
      _return.add(new Position(x, yiter.next()));
    }
  }
  return _return;
}
 
Example 16
Source File: DynamicGrid.java    From cineast with MIT License 5 votes vote down vote up
@Override
public void compact(){
  TIntIterator iter = grid.keySet().iterator();
  while(iter.hasNext()){
    int x = iter.next();
    TIntObjectHashMap<T> map = grid.get(x);
    if(map.isEmpty()){
      grid.remove(x);
    }else{
      map.compact();
    }
  }
  grid.compact();
}
 
Example 17
Source File: IEJoin.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private int[] getSortedArray(Cluster c, ParsedColumn<?> column, Order order) {
	int[] array = new int[c.size()];
	TIntIterator iter = c.iterator();
	int i = 0;
	while (iter.hasNext()) {
		array[i++] = iter.next();
	}
	final int cIndex = column.getIndex();

	IntComparator comp = (i1, i2) -> Integer.compare(values[order == Order.DESCENDING ? i2 : i1][cIndex], values[order == Order.DESCENDING ? i1 : i2][cIndex]);
	Primitive.sort(array,comp, false);
	return array;
}
 
Example 18
Source File: ColumnAwareEvidenceSetBuilder.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
private static void forEachLine(List<OrderedCluster> clusters, BiConsumer<Integer, Integer> consumer) {
	int clusterIndex = 0;
	for (OrderedCluster cluster : clusters) {
		TIntIterator iter = cluster.iterator();
		while (iter.hasNext()) {
			int line1 = iter.next();
			consumer.accept(Integer.valueOf(clusterIndex), Integer.valueOf(line1));
		}
		++clusterIndex;
	}
}
 
Example 19
Source File: CocktailParty.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
private void traceEntityRemovalStep(Graph graph, int removableMinimumNode, double removableMinimumWeightedDegree) {
  TIntLinkedList entityMentions = getEntityMentionsNodesIds(graph, removableMinimumNode);
  GraphNode node = graph.getNode(removableMinimumNode);
  int entity = (int) node.getNodeData();
  List<String> entityMentionsStringsIds = new LinkedList<String>();
  TIntIterator iterator = entityMentions.iterator();
  while (iterator.hasNext()) {
    int mentionNodeId = iterator.next();
    GraphNode mentionNode = graph.getNode(mentionNodeId);
    Mention mention = (Mention) mentionNode.getNodeData();
    String mentionIdString = mention.getIdentifiedRepresentation();
    entityMentionsStringsIds.add(mentionIdString);
  }
  GraphTracer.gTracer.addEntityRemovalStep(graph.getName(), entity, removableMinimumWeightedDegree, entityMentionsStringsIds);
}
 
Example 20
Source File: InitialAlgebra.java    From CQL with GNU Affero General Public License v3.0 5 votes vote down vote up
private synchronized int nf0(En en, Term<Void, En, Void, Fk, Void, Gen, Void> term) {
	int xx = nfs.get(term);
	if (xx != -1) {
		return xx;
	}
	TIntIterator it = ens.get(en).iterator();
	while (it.hasNext()) {
		int x = it.next();
		if (dp_en.eq(null, term, repr(en, x))) {
			nfs.put(term, x);
			return x;
		}
	}
	return -1;
}