You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2015/01/21 17:29:08 UTC
svn commit: r1653583 -
/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/IntBitSet.java
Author: schor
Date: Wed Jan 21 16:29:07 2015
New Revision: 1653583
URL: http://svn.apache.org/r1653583
Log:
[UIMA-4192][UIMA-4193]fix mixed up use of offset to be consistent. Add toString method for future debugging
Modified:
uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/IntBitSet.java
Modified: uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/IntBitSet.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/IntBitSet.java?rev=1653583&r1=1653582&r2=1653583&view=diff
==============================================================================
--- uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/IntBitSet.java (original)
+++ uima/uimaj/trunk/uimaj-core/src/main/java/org/apache/uima/internal/util/IntBitSet.java Wed Jan 21 16:29:07 2015
@@ -99,7 +99,7 @@ public class IntBitSet implements Positi
/**
*
- * @param key -
+ * @param key - the integer (not adjusted for offset)
* @return -
*/
@Override
@@ -187,12 +187,15 @@ public class IntBitSet implements Positi
@Override
public int get(int position) {
- assert(set.get(position));
- return position + offset;
+ assert(set.get(position - offset));
+ return position;
}
private class IntBitSetIterator implements IntListIterator {
+ /**
+ * This is the bit set position ***WITHOUT OFFSET***
+ */
protected int curKey;
protected IntBitSetIterator() {
@@ -249,22 +252,22 @@ public class IntBitSet implements Positi
@Override
public int moveToFirst() {
- return set.nextSetBit(0);
+ return set.nextSetBit(0) + offset;
}
@Override
public int moveToLast() {
- return set.length() - 1;
+ return set.length() - 1 + offset;
}
@Override
public int moveToNext(int position) {
- return set.nextSetBit(position + 1);
+ return set.nextSetBit(position - offset + 1) + offset;
}
@Override
public int moveToPrevious(int position) {
- return set.previousSetBit(position - 1);
+ return set.previousSetBit(position - offset - 1) + offset;
}
/**
@@ -273,9 +276,12 @@ public class IntBitSet implements Positi
*/
@Override
public boolean isValid(int position) {
- return (position >= 0) && set.get(position);
+ return (position >= offset) && set.get(position - offset);
}
+ /**
+ * Add all elements of this bit set to the passed in IntVector
+ */
@Override
public void bulkAddTo(IntVector v) {
int pos = -1;
@@ -291,7 +297,7 @@ public class IntBitSet implements Positi
return PositiveIntSet_impl.EMPTY_INT_ARRAY;
}
final int[] r = new int[s];
- int pos = moveToFirst();
+ int pos = moveToFirst() - offset;
for (int i = 0; i < s; i++) {
r[i] = pos + offset;
pos = set.nextSetBit(pos + 1);
@@ -299,4 +305,12 @@ public class IntBitSet implements Positi
return r;
}
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return String.format("IntBitSet [set=%s, size=%s, offset=%s]", set, size, offset);
+ }
+
}