Skip to content

Commit bd52696

Browse files
committed
fixes, cleanups, convenience
1 parent 317626d commit bd52696

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

commons/util/src/main/java/net/automatalib/commons/util/collections/PositiveIntSet.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.util.AbstractSet;
1919
import java.util.BitSet;
20-
import java.util.Iterator;
2120
import java.util.Set;
2221

2322
import org.checkerframework.checker.nullness.qual.Nullable;
@@ -79,16 +78,24 @@ public boolean contains(@Nullable Object o) {
7978
return false;
8079
}
8180

82-
return delegate.get((Integer) o);
81+
return containsInt((Integer) o);
82+
}
83+
84+
public boolean containsInt(int integer) {
85+
return delegate.get(integer);
8386
}
8487

8588
@Override
86-
public Iterator<Integer> iterator() {
89+
public BitSetIterator iterator() {
8790
return new BitSetIterator(delegate, immutable);
8891
}
8992

9093
@Override
9194
public boolean add(Integer integer) {
95+
return addInt(integer);
96+
}
97+
98+
public boolean addInt(int integer) {
9299
if (immutable) {
93100
throw new UnsupportedOperationException("This is a read-only set-view");
94101
}
@@ -101,17 +108,20 @@ public boolean add(Integer integer) {
101108

102109
@Override
103110
public boolean remove(@Nullable Object o) {
104-
if (immutable) {
105-
throw new UnsupportedOperationException("This is a read-only set-view");
106-
}
107-
108111
if (!(o instanceof Integer)) {
109112
return false;
110113
}
111114

112-
int asInt = (Integer) o;
113-
boolean containedBefore = delegate.get(asInt);
114-
delegate.clear(asInt);
115+
return removeInt((Integer) o);
116+
}
117+
118+
public boolean removeInt(int integer) {
119+
if (immutable) {
120+
throw new UnsupportedOperationException("This is a read-only set-view");
121+
}
122+
123+
boolean containedBefore = delegate.get(integer);
124+
delegate.clear(integer);
115125
return containedBefore;
116126
}
117127

util/src/main/java/net/automatalib/util/automata/spa/SPAUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public static <I> boolean isRedundancyFree(SPAAlphabet<I> alphabet, ATRSequences
369369
final Alphabet<I> callAlphabet = alphabet.getCallAlphabet();
370370
return atrSequences.accessSequences.keySet().containsAll(callAlphabet) &&
371371
atrSequences.terminatingSequences.keySet().containsAll(callAlphabet) &&
372-
atrSequences.terminatingSequences.keySet().containsAll(callAlphabet);
372+
atrSequences.returnSequences.keySet().containsAll(callAlphabet);
373373
}
374374

375375
/**

util/src/main/java/net/automatalib/util/graphs/traversal/GraphTraversal.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static <N, E, D> boolean traverse(TraversalOrder order,
5959
IndefiniteGraph<N, E> graph,
6060
N initialNode,
6161
GraphTraversalVisitor<N, E, D> vis) {
62-
return traverse(order, graph, -1, Collections.singleton(initialNode), vis);
62+
return traverse(order, graph, Collections.singleton(initialNode), vis);
6363
}
6464

6565
public static <N, E, D> boolean traverse(TraversalOrder order,
@@ -166,14 +166,14 @@ public static <N, E, D> boolean depthFirst(IndefiniteGraph<N, E> graph,
166166
public static <N, E, D> boolean depthFirst(IndefiniteGraph<N, E> graph,
167167
N initNode,
168168
GraphTraversalVisitor<N, E, D> vis) {
169-
return depthFirst(graph, -1, initNode, vis);
169+
return depthFirst(graph, Collections.singleton(initNode), vis);
170170
}
171171

172172
public static <N, E, D> boolean depthFirst(IndefiniteGraph<N, E> graph,
173173
int limit,
174174
N initNode,
175175
GraphTraversalVisitor<N, E, D> vis) {
176-
return depthFirst(graph, Collections.singleton(initNode), vis);
176+
return depthFirst(graph, limit, Collections.singleton(initNode), vis);
177177
}
178178

179179
public static <N, E, D> boolean depthFirst(IndefiniteGraph<N, E> graph,
@@ -282,13 +282,13 @@ public static <N, E, D> boolean breadthFirst(IndefiniteGraph<N, E> graph,
282282
public static <N, E, D> boolean breadthFirst(IndefiniteGraph<N, E> graph,
283283
N initialNode,
284284
GraphTraversalVisitor<N, E, D> visitor) {
285-
return breadthFirst(graph, -1, Collections.singleton(initialNode), visitor);
285+
return breadthFirst(graph, Collections.singleton(initialNode), visitor);
286286
}
287287

288288
public static <N, E, D> boolean dfs(IndefiniteGraph<N, E> graph,
289289
N initialNode,
290290
DFSVisitor<? super N, ? super E, D> visitor) {
291-
return dfs(graph, -1, Collections.singleton(initialNode), visitor);
291+
return dfs(graph, Collections.singleton(initialNode), visitor);
292292
}
293293

294294
public static <N, E, D> boolean dfs(IndefiniteGraph<N, E> graph,

util/src/main/java/net/automatalib/util/graphs/traversal/GraphTraversalVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public interface GraphTraversalVisitor<N, E, D> {
4747
* Called when the exploration of a node is started.
4848
*
4949
* @param node
50-
* the node which's exploration is about to be started
50+
* the node whose exploration is about to be started
5151
* @param data
5252
* the user data associated with this node
5353
*
@@ -59,7 +59,7 @@ public interface GraphTraversalVisitor<N, E, D> {
5959
* Called when the exploration of a node is finished.
6060
*
6161
* @param node
62-
* the node which's exploration is being finished
62+
* the node whose exploration is being finished
6363
* @param inData
6464
* the user data associated with this node
6565
*/

0 commit comments

Comments
 (0)