本文整理汇总了Java中com.carrotsearch.hppc.IntArrayList.contains方法的典型用法代码示例。如果您正苦于以下问题:Java IntArrayList.contains方法的具体用法?Java IntArrayList.contains怎么用?Java IntArrayList.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.carrotsearch.hppc.IntArrayList
的用法示例。
在下文中一共展示了IntArrayList.contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: minimize
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private void minimize() {
if (graph == null || isImmutable())
return;
IntArrayList verticesToRemove = new IntArrayList();
IntSet vertices = graph.getVertices();
if (!vertices.contains(entryNode) || !vertices.contains(targetNode)) {
graph = null;
return;
}
IntArrayList visitedFromStart = getVisited(entryNode, true);
IntArrayList visitedFromExit = getVisited(targetNode, false);
for (IntCursor nodeCur : vertices) {
int node = nodeCur.value;
if (!visitedFromStart.contains(node) || !visitedFromExit.contains(node)) {
verticesToRemove.add(node);
}
}
graph.removeVertices(verticesToRemove.toArray());
if (graph.getVertices().size() == 0 || graph.getEdges().size() == 0)
graph = null;
if (graph != null)
setImmutable();
}
示例2: getVisited
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private IntArrayList getVisited(int source, boolean forward) {
if (graph == null)
return new IntArrayList();
Queue<Integer> queue = new LinkedList<Integer>();
queue.add(source);
IntArrayList visited = new IntArrayList();
while (!queue.isEmpty()) {
Integer next = queue.poll();
if (!visited.contains(next)) {
visited.add(next);
IntSet edges = forward ? graph.getOutEdges(next) : graph.getInEdges(next);
for (IntCursor eCur : edges) {
int e = eCur.value;
int succNode;
if (forward) {
succNode = graph.getDirectedSimpleEdgeHead(e);
} else {
succNode = graph.getDirectedSimpleEdgeTail(e);
}
queue.add(succNode);
}
}
}
return visited;
}
示例3: getShortestPath
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
private IntArrayList getShortestPath(int source, int destination) {
if (graph == null)
return new IntArrayList();
Pair<Integer, Integer> key = new Pair<Integer, Integer>(source, destination);
if (isImmutable() && shortestPathCache.containsKey(key)) {
return shortestPathCache.get(key);
}
Queue<Integer> queue = new LinkedList<Integer>();
queue.add(source);
IntArrayList visited = new IntArrayList();
while (!queue.isEmpty()) {
Integer next = queue.poll();
if (!visited.contains(next)) {
visited.add(next);
IntSet edges = graph.getOutEdges(next);
for (IntCursor eCur : edges) {
int e = eCur.value;
int succNode = graph.getDirectedSimpleEdgeHead(e);
if (succNode == destination) {
if (!visited.contains(destination))
visited.add(destination);
shortestPathCache.put(key, visited);
return visited;
}
queue.add(succNode);
}
}
}
throw new RuntimeException("No path found");
}
示例4: hasLoops
import com.carrotsearch.hppc.IntArrayList; //导入方法依赖的package包/类
boolean hasLoops() {
if (graph == null)
return false;
if (isImmutable() && loopState == Loop.FALSE)
return false;
if (isImmutable() && loopState == Loop.TRUE)
return true;
Queue<Integer> queue = new LinkedList<Integer>();
queue.add(entryNode);
IntArrayList visited = new IntArrayList();
while (!queue.isEmpty()) {
Integer next = queue.poll();
if (visited.contains(next)) {
loopState = Loop.TRUE;
return true;
}
visited.add(next);
IntSet edges = graph.getOutEdges(next);
for (IntCursor e : edges) {
int succNode = graph.getDirectedSimpleEdgeHead(e.value);
queue.add(succNode);
}
}
loopState = Loop.FALSE;
return false;
}