--- src/java/org/apache/poi/util/IntList.java (revision b1ebde3d0c6836a46ee10d7d2db9b67400bbd14d) +++ src/java/org/apache/poi/util/IntList.java (revision 1454f9513743a0ab10f8dc494b484934cdd776cf) @@ -17,6 +17,8 @@ package org.apache.poi.util; +import java.util.Arrays; + /** * A List of int's; as full an implementation of the java.util.List * interface as possible, with an eye toward minimal creation of @@ -100,7 +102,6 @@ } else { - // index < limit -- insert into the middle if (_limit == _array.length) { @@ -229,16 +230,14 @@ public boolean contains(final int o) { - boolean rval = false; - - for (int j = 0; !rval && (j < _limit); j++) + for (int j = 0; j < _limit; j++) { if (_array[ j ] == o) { - rval = true; + return true; } } - return rval; + return false; } /** @@ -253,19 +252,17 @@ public boolean containsAll(final IntList c) { - boolean rval = true; - if (this != c) { - for (int j = 0; rval && (j < c._limit); j++) + for (int j = 0; j < c._limit; j++) { if (!contains(c._array[ j ])) { - rval = false; + return false; } } } - return rval; + return true; } /** @@ -286,24 +283,27 @@ public boolean equals(final Object o) { - boolean rval = this == o; + if (o == this) { + return true; + } + + if (o.getClass()!=this.getClass()) { + return false; + } - if (!rval && (o != null) && (o.getClass() == this.getClass())) - { - IntList other = ( IntList ) o; + IntList other = ( IntList ) o; - if (other._limit == _limit) - { - - // assume match - rval = true; - for (int j = 0; rval && (j < _limit); j++) - { - rval = _array[ j ] == other._array[ j ]; - } + if (other._limit != _limit) { + return false; + } + + for (int i=0; i< _limit; i++) { + if (other._array[i] != _array[i]) { + return false; } } - return rval; + + return true; } /** @@ -374,20 +374,12 @@ public int indexOf(final int o) { - int rval = 0; - - for (; rval < _limit; rval++) - { - if (o == _array[ rval ]) - { - break; + for (int i=0; i<_limit; i++) { + if (_array[i] == o) { + return i; } } - if (rval == _limit) - { - rval = -1; // didn't find it - } - return rval; + return -1; } /** @@ -416,16 +408,12 @@ public int lastIndexOf(final int o) { - int rval = _limit - 1; - - for (; rval >= 0; rval--) - { - if (o == _array[ rval ]) - { - break; + for (int i=_limit-1; i>=0; i--) { + if (_array[i] == o) { + return i; } } - return rval; + return -1; } /** @@ -469,9 +457,7 @@ public boolean removeValue(final int o) { - boolean rval = false; - - for (int j = 0; !rval && (j < _limit); j++) + for (int j = 0; j < _limit; j++) { if (o == _array[ j ]) { @@ -479,10 +465,10 @@ System.arraycopy(_array, j + 1, _array, j, _limit - j); } _limit--; - rval = true; + return true; } } - return rval; + return false; } /**