本文整理汇总了Java中gnu.trove.TIntIterator类的典型用法代码示例。如果您正苦于以下问题:Java TIntIterator类的具体用法?Java TIntIterator怎么用?Java TIntIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TIntIterator类属于gnu.trove包,在下文中一共展示了TIntIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: collapse
import gnu.trove.TIntIterator; //导入依赖的package包/类
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);
}
示例2: iterator
import gnu.trove.TIntIterator; //导入依赖的package包/类
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
public Iterator<Integer> iterator() {
return new Iterator<Integer>() {
private final TIntIterator it = _set.iterator();
public Integer next() {
return wrap(it.next());
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
示例3: iterator
import gnu.trove.TIntIterator; //导入依赖的package包/类
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
@Override
public Iterator<Integer> iterator() {
return new Iterator<Integer>() {
private final TIntIterator it = _set.iterator();
@Override
public Integer next() {
return wrap(it.next());
}
@Override
public boolean hasNext() {
return it.hasNext();
}
@Override
public void remove() {
it.remove();
}
};
}
示例4: iterator
import gnu.trove.TIntIterator; //导入依赖的package包/类
/**
* Creates an iterator over the values of the set.
*
* @return an iterator with support for removals in the underlying set
*/
public Iterator iterator() {
return new Iterator() {
private final TIntIterator it = _set.iterator();
public Object next() {
return wrap(it.next());
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
示例5: getTable
import gnu.trove.TIntIterator; //导入依赖的package包/类
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;
}
示例6: getTailsAndBody
import gnu.trove.TIntIterator; //导入依赖的package包/类
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;
}
示例7: save
import gnu.trove.TIntIterator; //导入依赖的package包/类
@Override
public void save(@NotNull DataOutput out, TIntHashSet value) throws IOException {
out.writeInt(value.size());
final TIntIterator iterator = value.iterator();
while (iterator.hasNext()) {
out.writeInt(iterator.next());
}
}
示例8: save
import gnu.trove.TIntIterator; //导入依赖的package包/类
@Override
public void save(DataOutput out, TIntHashSet value) throws IOException {
out.writeInt(value.size());
final TIntIterator iterator = value.iterator();
while (iterator.hasNext()) {
out.writeInt(iterator.next());
}
}
示例9: intersect
import gnu.trove.TIntIterator; //导入依赖的package包/类
/**
* This function computes the intersection of two sets.
*
* @param a
* @param b
* @return the set of elements contained in both sets
*/
public static TIntHashSet intersect(TIntHashSet a, TIntHashSet b) {
TIntHashSet result = new TIntHashSet();
for (TIntIterator iterator = a.iterator(); iterator.hasNext(); ) {
int x = iterator.next();
if (b.contains(x)) {
result.add(x);
}
}
return result;
}
示例10: constructEdges
import gnu.trove.TIntIterator; //导入依赖的package包/类
@Override
protected UndirectedWeightedListGraph constructEdges() {
int n = this.metricSpace.size();
TIntHashSet neighborhood = null;
UndirectedWeightedListGraph graph = new UndirectedWeightedListGraph(n);
for (int i = 0; i < n; i++) {
// obtain the neighborhood of the i-th point
neighborhood = this.metricSpace.getClosedNeighborhood(metricSpace.getPoint(i), this.maxDistance);
// get the pairwise distances of the points and store them
TIntIterator iterator = neighborhood.iterator();
while (iterator.hasNext()) {
int j = iterator.next();
if (i == j) {
continue;
}
double distance = this.metricSpace.distance(i, j);
graph.addEdge(i, j, distance);
}
}
return graph;
}
示例11: updateWitnessInformation
import gnu.trove.TIntIterator; //导入依赖的package包/类
protected void updateWitnessInformation(int n_star, double e_ij, int... externalIndices) {
TIntHashSet witnesses = this.getAllWitnesses(e_ij, externalIndices);
for (TIntIterator iterator = witnesses.iterator(); iterator.hasNext();) {
int witnessIndex = iterator.next();
if (!this.witnessSimplexMap.contains(witnessIndex)) {
this.witnessSimplexMap.put(witnessIndex, new ArrayList<Simplex>());
}
this.witnessSimplexMap.get(witnessIndex).add(Simplex.makeSimplex(externalIndices));
}
}
示例12: computeLandmarkSet
import gnu.trove.TIntIterator; //导入依赖的package包/类
@Override
protected int[] computeLandmarkSet() {
TIntHashSet landmarkSet = RandomUtility.randomSubset(this.landmarkSetSize, this.metricSpace.size());
int[] indices = new int[this.landmarkSetSize];
int index = 0;
for (TIntIterator iterator = landmarkSet.iterator(); iterator.hasNext(); ) {
indices[index] = iterator.next();
index++;
}
return indices;
}
示例13: computeMinDistance
import gnu.trove.TIntIterator; //导入依赖的package包/类
/**
* This function computes the function f(z) = min{d(z, l_0), ...., d(z, l_{i-1}}.
*
* @param queryPointIndex the index of the argument z in the above expression
* @param existingLandmarkPoints the set {l_0, ..., l_{i-1}}
* @return the value min{d(z, l_0), ...., d(z, l_{i-1}}
*/
private double computeMinDistance(int queryPointIndex, TIntHashSet existingLandmarkPoints) {
double minDistance = Infinity.Double.getPositiveInfinity();
for (TIntIterator iterator = existingLandmarkPoints.iterator(); iterator.hasNext(); ) {
minDistance = Math.min(minDistance, this.metricSpace.distance(queryPointIndex, iterator.next()));
}
return minDistance;
}
示例14: computeIntersection
import gnu.trove.TIntIterator; //导入依赖的package包/类
/**
* This function computes the intersection between two sets of
* integers.
*
* @param set1 the first set
* @param set2 the second set
* @return a TIntSet containing elements common to both input sets
*/
public static TIntHashSet computeIntersection(TIntHashSet set1, TIntHashSet set2) {
TIntHashSet smallerSet = null;
TIntHashSet largerSet = null;
/*
* Let's identify the smaller and larger sets,
* so that we only need to iterate through the smaller one.
*/
if (set1.size() < set2.size()) {
smallerSet = set1;
largerSet = set2;
} else {
smallerSet = set2;
largerSet = set1;
}
TIntHashSet intersection = new TIntHashSet();
TIntIterator iterator = smallerSet.iterator();
while (iterator.hasNext()) {
int element = iterator.next();
if (largerSet.contains(element)) {
intersection.add(element);
}
}
return intersection;
}
示例15: pullUpIndices
import gnu.trove.TIntIterator; //导入依赖的package包/类
protected static TIntHashSet pullUpIndices(TIntHashSet subIndices, TIntHashSet indices) {
TIntHashSet result = new TIntHashSet();
TIntIterator iterator = subIndices.iterator();
int[] indicesArray = indices.toArray();
while (iterator.hasNext()) {
int subIndex = iterator.next();
result.add(indicesArray[subIndex]);
}
return result;
}