本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntSet.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java IntSet.iterator方法的具体用法?Java IntSet.iterator怎么用?Java IntSet.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.ints.IntSet
的用法示例。
在下文中一共展示了IntSet.iterator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLocalsChange
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
private DebugLocalsChange createLocalsChange(
Int2ReferenceMap<DebugLocalInfo> ending, Int2ReferenceMap<DebugLocalInfo> starting) {
if (ending.isEmpty() && starting.isEmpty()) {
return null;
}
if (ending.isEmpty() || starting.isEmpty()) {
return new DebugLocalsChange(ending, starting);
}
IntSet unneeded = new IntArraySet(Math.min(ending.size(), starting.size()));
for (Entry<DebugLocalInfo> entry : ending.int2ReferenceEntrySet()) {
if (starting.get(entry.getIntKey()) == entry.getValue()) {
unneeded.add(entry.getIntKey());
}
}
if (unneeded.size() == ending.size() && unneeded.size() == starting.size()) {
return null;
}
IntIterator iterator = unneeded.iterator();
while (iterator.hasNext()) {
int key = iterator.nextInt();
ending.remove(key);
starting.remove(key);
}
return new DebugLocalsChange(ending, starting);
}
示例2: createNewAttribute
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public Attribute createNewAttribute(HashMap<String, Attribute> attributes,
String attribute, int noMonths) {
Attribute a = attributes.get(attribute);
int ct = 0;
IntSet keys = a.data.keySet();
IntIterator it = keys.iterator();
ArrayList<SpatioTemporalVal> arr = new ArrayList<SpatioTemporalVal>();
while(ct < noMonths) {
if(!it.hasNext()) {
Utilities.er("no. of months is greater than what is present");
}
int month = it.nextInt();
arr.addAll(a.data.get(month));
ct++;
}
Collections.sort(arr);
Attribute na = new Attribute();
na.data.put(0, arr);
na.nodeSet = a.nodeSet;
return na;
}
示例3: getWeightedRandomReversed
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
@Nullable
public static <T> T getWeightedRandomReversed(Random random, Int2ObjectMap<T> choices)
{
long i = 0;
IntSet ints = choices.keySet();
for (IntIterator iterator = ints.iterator(); iterator.hasNext(); )
{
int x = iterator.nextInt();
i += x;
}
i = getRandomLong(random, 0, i);
for (Int2ObjectMap.Entry<T> entry : choices.int2ObjectEntrySet())
{
i -= entry.getIntKey();
if (i < 0)
{
return entry.getValue();
}
}
return null;
}
示例4: detectBorderNodes
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public List<Node> detectBorderNodes(ProcessingTile tile, int imageWidth, int imageHeight) {
List<Node> result = new ArrayList<Node>();
int nodeCount = this.nodes.size();
for (int i=0; i<nodeCount; i++) {
Node node = this.nodes.get(i);
BoundingBox box = node.getBox();
if (box.getLeftX() > tile.getImageLeftX() && box.getTopY() > tile.getImageTopY() && box.getRightX() - 1 < tile.getImageRightX() && box.getBottomY() - 1 < tile.getImageBottomY()) {
// the node is inside the tile
continue;
} else {
// the node is on the tile margin or outside the tile
IntSet borderCells = AbstractSegmenter.generateBorderCells(node.getContour(), node.getId(), imageWidth);
IntIterator itCells = borderCells.iterator();
while (itCells.hasNext()) {
int gridIdInImage = itCells.nextInt();
int rowPixelInImage = gridIdInImage / imageWidth;
int colPixelInImage = gridIdInImage % imageWidth;
if (tile.getImageTopY() > 0 && rowPixelInImage == tile.getImageTopY()) {
result.add(node);
break;
} else if (tile.getImageRightX() < imageWidth - 1 && colPixelInImage == tile.getImageRightX()) {
result.add(node);
break;
} else if (tile.getImageBottomY() < imageHeight - 1 && rowPixelInImage == tile.getImageBottomY()) {
result.add(node);
break;
} else if (tile.getImageLeftX() > 0 && colPixelInImage == tile.getImageLeftX()) {
result.add(node);
break;
}
}
}
}
return result;
}
示例5: removeUnstableSegments
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public void removeUnstableSegments(ProcessingTile tile, int imageWidth) {
int nodeCount = this.nodes.size();
for (int i=0; i<nodeCount; i++) {
Node node = this.nodes.get(i);
BoundingBox box = node.getBox();
if (box.getLeftX() >= tile.getImageLeftX() && box.getTopY() >= tile.getImageTopY() && box.getRightX() - 1 <= tile.getImageRightX() && box.getBottomY() - 1 <= tile.getImageBottomY()) {
continue;
} else if (box.getLeftX() > tile.getImageRightX() || box.getTopY() > tile.getImageBottomY() || box.getRightX() - 1 < tile.getImageLeftX()
|| box.getBottomY() - 1 < tile.getImageTopY()) {
node.setExpired(true);
removeEdgeToUnstableNode(node);
} else {
boolean stable = false;
IntSet borderCells = AbstractSegmenter.generateBorderCells(node.getContour(), node.getId(), imageWidth);
IntIterator itCells = borderCells.iterator();
while (itCells.hasNext()) {
int gridIdInImage = itCells.nextInt();
int rowPixelInImage = gridIdInImage / imageWidth;
int colPixelInImage = gridIdInImage % imageWidth;
if (rowPixelInImage >= tile.getImageTopY() && rowPixelInImage <= tile.getImageBottomY() && colPixelInImage >= tile.getImageLeftX() && colPixelInImage <= tile.getImageRightX()) {
stable = true;
break;
}
}
if (!stable) {
node.setExpired(true);
removeEdgeToUnstableNode(node);
}
}
}
removeExpiredNodes();
}
示例6: findUselessNodes
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public List<Node> findUselessNodes(ProcessingTile tile, int imageWidth) {
List<Node> nodesToIterate = new ArrayList<Node>();
int nodeCount = this.nodes.size();
for (int i=0; i<nodeCount; i++) {
Node node = this.nodes.get(i);
BoundingBox box = node.getBox();
if (box.getLeftX() > tile.getImageLeftX() && box.getTopY() > tile.getImageTopY() && box.getRightX() - 1 < tile.getImageRightX() && box.getBottomY() - 1 < tile.getImageBottomY()) {
continue;
} else if (box.getLeftX() > tile.getImageRightX() || box.getTopY() > tile.getImageBottomY() || box.getRightX() - 1 < tile.getImageLeftX() || box.getBottomY() - 1 < tile.getImageTopY()) {
continue;
} else {
IntSet borderCells = AbstractSegmenter.generateBorderCells(node.getContour(), node.getId(), imageWidth);
IntIterator itCells = borderCells.iterator();
while (itCells.hasNext()) {
int gridId = itCells.nextInt();
int rowPixel = gridId / imageWidth;
int colPixel = gridId % imageWidth;
if (rowPixel == tile.getImageTopY() || rowPixel == tile.getImageBottomY()) {
if (colPixel >= tile.getImageLeftX() && colPixel <= tile.getImageRightX()) {
nodesToIterate.add(node);
break;
}
} else if (colPixel == tile.getImageLeftX() || colPixel == tile.getImageRightX()) {
if (rowPixel >= tile.getImageTopY() && rowPixel <= tile.getImageBottomY()) {
nodesToIterate.add(node);
break;
}
}
}
}
}
return nodesToIterate;
}
示例7: removeDuplicatedNodes
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public void removeDuplicatedNodes(Int2ObjectMap<List<Node>> borderPixelMap, int imageWidth) {
ObjectIterator<Int2ObjectMap.Entry<List<Node>>> it = borderPixelMap.int2ObjectEntrySet().iterator();
while (it.hasNext()) {
Int2ObjectMap.Entry<List<Node>> entry = it.next();
List<Node> nodes = entry.getValue();
if (nodes.size() > 1) {
Node refNode = nodes.get(0); // refNode
// explore duplicated nodes
for (int i=1; i<nodes.size(); i++) {
Node currentNode = nodes.get(i);
int edgeCount = currentNode.getEdgeCount();
for (int k=0; k<edgeCount; k++) {
Edge edge = currentNode.getEdgeAt(k);
Node neighNit = edge.getTarget();
int removedEdgeIndex = neighNit.removeEdge(currentNode);
assert(removedEdgeIndex >= 0);
Edge edgeToFirstNode = neighNit.findEdge(refNode);
if (edgeToFirstNode == null) {
// create an edge neighNit -> refNode
neighNit.addEdge(refNode, edge.getBoundary());
// create an edge refNode -> neighNit
refNode.addEdge(neighNit, edge.getBoundary());
}
}
currentNode.setExpired(true);
}
IntSet borderCells = AbstractSegmenter.generateBorderCells(refNode.getContour(), refNode.getId(), imageWidth);
IntIterator itCells = borderCells.iterator();
while (itCells.hasNext()) {
int gridId = itCells.nextInt();
List<Node> resultNodes = borderPixelMap.get(gridId);
if (resultNodes != null) {
resultNodes.clear();
resultNodes.add(refNode);
}
}
}
}
removeExpiredNodes();
}
示例8: testGenerateBorderCells
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
@Test
public void testGenerateBorderCells() {
Contour contour = new Contour();
contour.pushRight();
contour.pushRight();
contour.pushRight();
contour.pushBottom();
contour.pushBottom();
contour.pushBottom();
contour.pushLeft();
contour.pushLeft();
contour.pushLeft();
contour.pushTop();
contour.pushTop();
contour.pushTop();
IntSet borderCells = AbstractSegmenter.generateBorderCells(contour, 100, 1000);
assertEquals(8, borderCells.size());
IntIterator iterator = borderCells.iterator();
int cellId = iterator.nextInt();
assertEquals(2100, cellId);
cellId = iterator.nextInt();
assertEquals(2101, cellId);
cellId = iterator.nextInt();
assertEquals(2102, cellId);
cellId = iterator.nextInt();
assertEquals(1100, cellId);
cellId = iterator.nextInt();
assertEquals(100, cellId);
cellId = iterator.nextInt();
assertEquals(102, cellId);
cellId = iterator.nextInt();
assertEquals(101, cellId);
cellId = iterator.nextInt();
assertEquals(1102, cellId);
}
示例9: EdgeIterable
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public EdgeIterable(IGraph g, IntSet edges) {
this.g = g;
this.edgeIterator = edges.iterator();
}