Skip to content

Commit a58c1c0

Browse files
committed
#5 Get rid of generics-related warnings.
1 parent e8f0f78 commit a58c1c0

File tree

6 files changed

+60
-59
lines changed

6 files changed

+60
-59
lines changed

src/main/java/com/github/javabdd/BDD.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,10 @@ public AllSatIterator allsat() {
676676
* Iterator that returns all satisfying assignments as byte arrays. In the byte arrays, -1 means dont-care, 0 means
677677
* 0, and 1 means 1.
678678
*/
679-
public static class AllSatIterator implements Iterator {
679+
public static class AllSatIterator implements Iterator<byte[]> {
680680
protected final BDDFactory f;
681681

682-
protected LinkedList loStack, hiStack;
682+
protected LinkedList<BDD> loStack, hiStack;
683683

684684
protected byte[] allsatProfile;
685685

@@ -717,8 +717,8 @@ public AllSatIterator(BDD r, boolean lev) {
717717
if (!f.isZDD()) {
718718
Arrays.fill(allsatProfile, (byte)-1);
719719
}
720-
loStack = new LinkedList();
721-
hiStack = new LinkedList();
720+
loStack = new LinkedList<>();
721+
hiStack = new LinkedList<>();
722722
if (!r.isOne()) {
723723
loStack.addLast(r.id());
724724
if (!gotoNext()) {
@@ -735,9 +735,9 @@ private boolean gotoNext() {
735735
if (hiStack.isEmpty()) {
736736
return false;
737737
}
738-
r = (BDD)hiStack.removeLast();
738+
r = hiStack.removeLast();
739739
} else {
740-
r = (BDD)loStack.removeLast();
740+
r = loStack.removeLast();
741741
}
742742
int LEVEL_r = r.level();
743743
allsatProfile[useLevel ? LEVEL_r : f.level2Var(LEVEL_r)] = lo_empty ? (byte)1 : (byte)0;
@@ -811,7 +811,7 @@ public byte[] nextSat() {
811811
* @see java.util.Iterator#next()
812812
*/
813813
@Override
814-
public Object next() {
814+
public byte[] next() {
815815
return nextSat();
816816
}
817817

@@ -945,7 +945,7 @@ public BDDIterator iterator(final BDDVarSet var) {
945945
* @author jwhaley
946946
* @version $Id: BDD.java 481 2011-02-18 14:37:09Z gismo $
947947
*/
948-
public static class BDDIterator implements Iterator {
948+
public static class BDDIterator implements Iterator<BDD> {
949949
final BDDFactory f;
950950

951951
final AllSatIterator i;
@@ -985,7 +985,7 @@ public BDDIterator(BDD bdd, BDDVarSet var) {
985985

986986
protected void gotoNext() {
987987
if (i.hasNext()) {
988-
a = (byte[])i.next();
988+
a = i.next();
989989
} else {
990990
a = null;
991991
return;
@@ -1031,7 +1031,7 @@ public boolean hasNext() {
10311031
* @see java.util.Iterator#next()
10321032
*/
10331033
@Override
1034-
public Object next() {
1034+
public BDD next() {
10351035
return nextBDD();
10361036
}
10371037

@@ -1337,20 +1337,20 @@ public void printDot() {
13371337
boolean[] visited = new boolean[nodeCount() + 2];
13381338
visited[0] = true;
13391339
visited[1] = true;
1340-
HashMap map = new HashMap();
1340+
HashMap<BDD, Integer> map = new HashMap<>();
13411341
map.put(getFactory().zero(), 0);
13421342
map.put(getFactory().one(), 1);
13431343
printdot_rec(out, 1, visited, map);
13441344

1345-
for (Iterator i = map.keySet().iterator(); i.hasNext();) {
1346-
BDD b = (BDD)i.next();
1345+
for (Iterator<BDD> i = map.keySet().iterator(); i.hasNext();) {
1346+
BDD b = i.next();
13471347
b.free();
13481348
}
13491349
out.println("}");
13501350
}
13511351

1352-
protected int printdot_rec(PrintStream out, int current, boolean[] visited, HashMap map) {
1353-
Integer ri = ((Integer)map.get(this));
1352+
protected int printdot_rec(PrintStream out, int current, boolean[] visited, HashMap<BDD, Integer> map) {
1353+
Integer ri = (map.get(this));
13541354
if (ri == null) {
13551355
map.put(this.id(), ri = ++current);
13561356
}
@@ -1364,12 +1364,12 @@ protected int printdot_rec(PrintStream out, int current, boolean[] visited, Hash
13641364
out.println(r + " [label=\"" + this.var() + "\"];");
13651365

13661366
BDD l = this.low(), h = this.high();
1367-
Integer li = (Integer)map.get(l);
1367+
Integer li = map.get(l);
13681368
if (li == null) {
13691369
map.put(l.id(), li = ++current);
13701370
}
13711371
int low = li.intValue();
1372-
Integer hi = (Integer)map.get(h);
1372+
Integer hi = map.get(h);
13731373
if (hi == null) {
13741374
map.put(h.id(), hi = ++current);
13751375
}

src/main/java/com/github/javabdd/BDDFactory.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static BDDFactory init(String bddpackage, int nodenum, int cachesize) {
8888
System.err.println("Could not load BDD package " + bddpackage + ": " + e.getLocalizedMessage());
8989
}
9090
try {
91-
Class c = Class.forName(bddpackage);
91+
Class<?> c = Class.forName(bddpackage);
9292
Method m = c.getMethod("init", new Class[] {int.class, int.class});
9393
return (BDDFactory)m.invoke(null, new Object[] {nodenum, cachesize});
9494
} catch (ClassNotFoundException e) {
@@ -251,12 +251,12 @@ public BDDVarSet emptySet() {
251251
* Compare to bdd_buildcube.
252252
* </p>
253253
*/
254-
public BDD buildCube(int value, List/* <BDD> */ variables) {
254+
public BDD buildCube(int value, List<BDD> variables) {
255255
BDD result = universe();
256-
Iterator i = variables.iterator();
256+
Iterator<BDD> i = variables.iterator();
257257
// int z = 0;
258258
while (i.hasNext()) {
259-
BDD var = (BDD)i.next();
259+
BDD var = i.next();
260260
if ((value & 0x1) != 0) {
261261
var = var.id();
262262
} else {
@@ -1265,7 +1265,7 @@ public void addVarBlock(BDDVarSet var, boolean fixed) {
12651265
* Compare to bdd_anodecount.
12661266
* </p>
12671267
*/
1268-
public abstract int nodeCount(Collection/* BDD */ r);
1268+
public abstract int nodeCount(Collection<BDD> r);
12691269

12701270
/**
12711271
* <p>
@@ -2158,7 +2158,7 @@ public BDDBitVector buildVector(int[] var) {
21582158

21592159
///// CALLBACKS /////
21602160

2161-
protected List gc_callbacks, reorder_callbacks, resize_callbacks;
2161+
protected List<Object[]> gc_callbacks, reorder_callbacks, resize_callbacks;
21622162

21632163
/**
21642164
* <p>
@@ -2170,7 +2170,7 @@ public BDDBitVector buildVector(int[] var) {
21702170
*/
21712171
public void registerGCCallback(Object o, Method m) {
21722172
if (gc_callbacks == null) {
2173-
gc_callbacks = new LinkedList();
2173+
gc_callbacks = new LinkedList<>();
21742174
}
21752175
registerCallback(gc_callbacks, o, m);
21762176
}
@@ -2202,7 +2202,7 @@ public void unregisterGCCallback(Object o, Method m) {
22022202
*/
22032203
public void registerReorderCallback(Object o, Method m) {
22042204
if (reorder_callbacks == null) {
2205-
reorder_callbacks = new LinkedList();
2205+
reorder_callbacks = new LinkedList<>();
22062206
}
22072207
registerCallback(reorder_callbacks, o, m);
22082208
}
@@ -2234,7 +2234,7 @@ public void unregisterReorderCallback(Object o, Method m) {
22342234
*/
22352235
public void registerResizeCallback(Object o, Method m) {
22362236
if (resize_callbacks == null) {
2237-
resize_callbacks = new LinkedList();
2237+
resize_callbacks = new LinkedList<>();
22382238
}
22392239
registerCallback(resize_callbacks, o, m);
22402240
}
@@ -2314,7 +2314,7 @@ protected static void bdd_default_reshandler(int oldsize, int newsize) {
23142314
}
23152315
}
23162316

2317-
protected void registerCallback(List callbacks, Object o, Method m) {
2317+
protected void registerCallback(List<Object[]> callbacks, Object o, Method m) {
23182318
if (!Modifier.isPublic(m.getModifiers()) && !m.isAccessible()) {
23192319
throw new BDDException("Callback method not accessible");
23202320
}
@@ -2327,18 +2327,18 @@ protected void registerCallback(List callbacks, Object o, Method m) {
23272327
}
23282328
}
23292329
if (DEBUG) {
2330-
Class[] params = m.getParameterTypes();
2330+
Class<?>[] params = m.getParameterTypes();
23312331
if (params.length != 1 || params[0] != int.class) {
23322332
throw new BDDException("Wrong signature for callback");
23332333
}
23342334
}
23352335
callbacks.add(new Object[] {o, m});
23362336
}
23372337

2338-
protected boolean unregisterCallback(List callbacks, Object o, Method m) {
2338+
protected boolean unregisterCallback(List<Object[]> callbacks, Object o, Method m) {
23392339
if (callbacks != null) {
2340-
for (Iterator i = callbacks.iterator(); i.hasNext();) {
2341-
Object[] cb = (Object[])i.next();
2340+
for (Iterator<Object[]> i = callbacks.iterator(); i.hasNext();) {
2341+
Object[] cb = i.next();
23422342
if (o == cb[0] && m.equals(cb[1])) {
23432343
i.remove();
23442344
return true;
@@ -2348,10 +2348,10 @@ protected boolean unregisterCallback(List callbacks, Object o, Method m) {
23482348
return false;
23492349
}
23502350

2351-
protected void doCallbacks(List callbacks, Object arg1, Object arg2) {
2351+
protected void doCallbacks(List<Object[]> callbacks, Object arg1, Object arg2) {
23522352
if (callbacks != null) {
2353-
for (Iterator i = callbacks.iterator(); i.hasNext();) {
2354-
Object[] cb = (Object[])i.next();
2353+
for (Iterator<Object[]> i = callbacks.iterator(); i.hasNext();) {
2354+
Object[] cb = i.next();
23552355
Object o = cb[0];
23562356
Method m = (Method)cb[1];
23572357
try {

src/main/java/com/github/javabdd/BDDFactoryIntImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,10 @@ protected IntBDD makeBDD(/* bdd */int v) {
351351
return ((IntBDD)b).v;
352352
}
353353

354-
protected static final /* bdd */int[] unwrap(Collection/* <BDD> */ c) {
354+
protected static final /* bdd */int[] unwrap(Collection<BDD> c) {
355355
/* bdd */int[] result = new /* bdd */int[c.size()];
356356
int k = -1;
357-
for (Iterator i = c.iterator(); i.hasNext();) {
357+
for (Iterator<BDD> i = c.iterator(); i.hasNext();) {
358358
result[++k] = ((IntBDD)i.next()).v;
359359
}
360360
return result;
@@ -672,7 +672,7 @@ public BDD nithVar(/* bdd */int var) {
672672
}
673673

674674
@Override
675-
public int nodeCount(Collection/* <BDD> */ r) {
675+
public int nodeCount(Collection<BDD> r) {
676676
return nodeCount_impl2(unwrap(r));
677677
}
678678

src/main/java/com/github/javabdd/BitString.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,14 +685,14 @@ public BackwardBitStringIterator backwardsIterator(int i) {
685685
/**
686686
* Abstract bit string iterator class.
687687
*/
688-
public abstract static class BitStringIterator implements Iterator {
688+
public abstract static class BitStringIterator implements Iterator<Integer> {
689689
/**
690690
* Returns the index of the next bit set.
691691
*/
692692
public abstract int nextIndex();
693693

694694
@Override
695-
public final Object next() {
695+
public final Integer next() {
696696
return nextIndex();
697697
}
698698

src/main/java/com/github/javabdd/JFactory.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,11 @@ protected void reverseDomain0(BDDDomain d) {
701701
}
702702

703703
public void setVarOrder(String ordering) {
704-
List result = new LinkedList();
704+
List<Object> result = new LinkedList<>();
705705
int nDomains = numberOfDomains();
706706
StringTokenizer st = new StringTokenizer(ordering, "x_", true);
707707
boolean[] done = new boolean[nDomains];
708-
List last = null;
708+
List<BDDDomain> last = null;
709709
for (/* int i=0 */;; /* ++i */) {
710710
String s = st.nextToken();
711711
BDDDomain d;
@@ -729,7 +729,7 @@ public void setVarOrder(String ordering) {
729729
s = st.nextToken();
730730
if (s.equals("x")) {
731731
if (last == null) {
732-
last = new LinkedList();
732+
last = new LinkedList<>();
733733
last.add(d);
734734
result.add(last);
735735
}
@@ -765,20 +765,21 @@ public void setVarOrder(String ordering) {
765765
*
766766
* @param domains domain order
767767
*/
768-
public void setVarOrder(List domains) {
768+
@SuppressWarnings("unchecked")
769+
public void setVarOrder(List<Object> domains) {
769770
BddTree[] my_vartree = new BddTree[fdvarnum];
770771
boolean[] interleaved = new boolean[fdvarnum];
771772
int k = 0;
772-
for (Iterator i = domains.iterator(); i.hasNext();) {
773+
for (Iterator<Object> i = domains.iterator(); i.hasNext();) {
773774
Object o = i.next();
774-
Collection c;
775+
Collection<BDDDomain> c;
775776
if (o instanceof BDDDomain) {
776-
c = Collections.singleton(o);
777+
c = Collections.singleton((BDDDomain)o);
777778
} else {
778-
c = (Collection)o;
779+
c = (Collection<BDDDomain>)o;
779780
}
780-
for (Iterator j = c.iterator(); j.hasNext();) {
781-
BDDDomain d = (BDDDomain)j.next();
781+
for (Iterator<BDDDomain> j = c.iterator(); j.hasNext();) {
782+
BDDDomain d = j.next();
782783
int low = d.ivar[0];
783784
int high = d.ivar[d.ivar.length - 1];
784785
bdd_intaddvarblock(low, high, false);

src/main/java/com/github/javabdd/TryVarOrder.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void initBDDFactory(String s) {
4343
} else {
4444
cl = makeClassLoader();
4545
}
46-
Class c = cl.loadClass("com.github.javabdd.BDDFactory");
46+
Class<?> c = cl.loadClass("com.github.javabdd.BDDFactory");
4747
Method m = c.getMethod("init", new Class[] {String.class, int.class, int.class});
4848
bdd = m.invoke(null, new Object[] {s, nodeTableSize, cacheSize});
4949
m = c.getMethod("setMaxIncrease", new Class[] {int.class});
@@ -82,7 +82,7 @@ void initBDDFactory(String s) {
8282
*/
8383
void destroyBDDFactory() {
8484
if (bdd != null) {
85-
Class c = bdd.getClass();
85+
Class<?> c = bdd.getClass();
8686
try {
8787
Method m = c.getMethod("done", new Class[] {});
8888
m.invoke(bdd, new Object[] {});
@@ -95,7 +95,7 @@ void destroyBDDFactory() {
9595
}
9696

9797
void setBDDError(int code) {
98-
Class c = bdd.getClass();
98+
Class<?> c = bdd.getClass();
9999
try {
100100
Method m = c.getMethod("setError", new Class[] {int.class});
101101
m.invoke(bdd, new Object[] {code});
@@ -113,7 +113,7 @@ void setBDDError(int code) {
113113
* @param bits bits in domain
114114
* @throws Exception In case of an error.
115115
*/
116-
static void makeDomain(Class c, String name, int bits) throws Exception {
116+
static void makeDomain(Class<?> c, String name, int bits) throws Exception {
117117
Method m = c.getMethod("extDomain", new Class[] {long[].class});
118118
Object[] ds = (Object[])m.invoke(null, new Object[] {new long[] {1L << bits}});
119119
c = c.getClassLoader().loadClass("com.github.javabdd.BDDDomain");
@@ -130,8 +130,8 @@ void initBDDOperation() throws Exception {
130130
} else {
131131
cl = makeClassLoader();
132132
}
133-
Class bddop_class = cl.loadClass("com.github.javabdd.TryVarOrder$BDDOperation");
134-
Constructor c = bddop_class.getConstructor(new Class[0]);
133+
Class<?> bddop_class = cl.loadClass("com.github.javabdd.TryVarOrder$BDDOperation");
134+
Constructor<?> c = bddop_class.getConstructor(new Class[0]);
135135
bddoperation = c.newInstance((Object[])null);
136136
Method m = bddop_class.getMethod("setOp", new Class[] {int.class});
137137
m.invoke(bddoperation, new Object[] {op.id});
@@ -140,26 +140,26 @@ void initBDDOperation() throws Exception {
140140
}
141141

142142
void setVarOrder(boolean reverse, String varOrderToTry) throws Exception {
143-
Class bddop_class = bddoperation.getClass();
143+
Class<?> bddop_class = bddoperation.getClass();
144144
Method m = bddop_class.getMethod("setVarOrder", new Class[] {boolean.class, String.class});
145145
m.invoke(bddoperation, new Object[] {Boolean.valueOf(reverse), varOrderToTry});
146146
}
147147

148148
void load() throws Exception {
149-
Class bddop_class = bddoperation.getClass();
149+
Class<?> bddop_class = bddoperation.getClass();
150150
Method m = bddop_class.getMethod("load", new Class[] {});
151151
m.invoke(bddoperation, new Object[] {});
152152
}
153153

154154
long doIt() throws Exception {
155-
Class bddop_class = bddoperation.getClass();
155+
Class<?> bddop_class = bddoperation.getClass();
156156
Method m = bddop_class.getMethod("doIt", new Class[] {});
157157
Long result = (Long)m.invoke(bddoperation, new Object[] {});
158158
return result.longValue();
159159
}
160160

161161
void free() throws Exception {
162-
Class bddop_class = bddoperation.getClass();
162+
Class<?> bddop_class = bddoperation.getClass();
163163
Method m = bddop_class.getMethod("free", new Class[] {});
164164
m.invoke(bddoperation, new Object[] {});
165165
}

0 commit comments

Comments
 (0)