Permalink
Browse files

Revert "TermValueLists now have starting and ending offset support."

This reverts commit a31b44a.
  • Loading branch information...
1 parent 1fbb7ba commit db8685bde708ea6c1de8b238162ace0c9764d060 Joshua Hartman committed May 28, 2013
@@ -49,15 +49,16 @@ public boolean containsWithType(char val)
}
@Override
- public int indexOfWithOffset(Object o, int startingOffset, int endingOffset) {
+ public int indexOf(Object o)
+ {
char val;
if (o instanceof String)
val = parse((String)o);
else
val = (Character)o;
-
- return Arrays.binarySearch(_elements, startingOffset, endingOffset, val);
- }
+ char[] elements=((CharArrayList)_innerList).elements();
+ return Arrays.binarySearch(elements, val);
+ }
@Override
public int indexOfWithType(Character val)
@@ -74,14 +74,15 @@ public double getPrimitiveValue(int index)
}
@Override
- public int indexOfWithOffset(Object o, int startingOffset, int endingOffset) {
+ public int indexOf(Object o)
+ {
double val = parse((String) o);
if (o instanceof String)
val = parse((String)o);
else
val = (Double)o;
double[] elements = ((DoubleArrayList) _innerList).elements();
- return Arrays.binarySearch(elements, startingOffset, endingOffset, val);
+ return Arrays.binarySearch(elements, val);
}
public int indexOf(double val)
@@ -247,7 +247,7 @@ protected int binarySearch(long[] key, int low, int high)
while(low <= high)
{
- mid = low + ((high - low) >> 1);
+ mid = (low+high)/2;
index = mid * width;
for (i=0; i<width; ++i, ++index)
{
@@ -267,12 +267,13 @@ else if (cmp < 0)
}
@Override
- public int indexOfWithOffset(Object o, int startingOffset, int endingOffset) {
+ public int indexOf(Object o)
+ {
if (withDummy)
{
if (o instanceof String)
o = parse((String)o);
- return binarySearch((long[])o, startingOffset, endingOffset/width - 1);
+ return binarySearch((long[])o, 1, _elements.length/width - 1);
}
else
{
@@ -74,14 +74,15 @@ public float getPrimitiveValue(int index)
}
@Override
- public int indexOfWithOffset(Object o, int startingOffset, int endingOffset) {
+ public int indexOf(Object o)
+ {
float val;
if (o instanceof String)
val = parse((String) o);
else
val = (Float)o;
float[] elements = ((FloatArrayList) _innerList).elements();
- return Arrays.binarySearch(elements, startingOffset, endingOffset, val);
+ return Arrays.binarySearch(elements, val);
}
public int indexOf(float o)
@@ -86,6 +86,29 @@ public int getPrimitiveValue(int index)
return TermIntList.VALUE_MISSING;
}
+ @Override
+ public int indexOf(Object o)
+ {
+ if (withDummy)
+ {
+ if (o==null) return -1;
+ int val;
+ if (o instanceof String)
+ val = parse((String) o);
+ else
+ val = (Integer)o;
+ return Arrays.binarySearch(_elements, 1, _elements.length, val);
+ } else
+ {
+ int val;
+ if (o instanceof String)
+ val = parse((String) o);
+ else
+ val = (Integer)o;
+ return Arrays.binarySearch(_elements, val);
+ }
+ }
+
public int indexOf(Integer value)
{
if (withDummy)
@@ -107,19 +130,19 @@ public int indexOf(int val)
}
@Override
- public int indexOfWithOffset(Object value, int startingOffset, int endingOffset)
+ public int indexOfWithOffset(Object value, int offset)
{
if (withDummy)
{
- if (value == null)
+ if (value == null || offset >= _elements.length)
return -1;
int val = parse(String.valueOf(value));
- return Arrays.binarySearch(_elements, startingOffset, endingOffset, val);
+ return Arrays.binarySearch(_elements, offset, _elements.length, val);
}
else
{
int val = parse(String.valueOf(value));
- return Arrays.binarySearch(_elements, startingOffset, endingOffset, val);
+ return Arrays.binarySearch(_elements, offset, _elements.length, val);
}
}
@@ -93,11 +93,6 @@ public long getPrimitiveValue(int index)
@Override
public int indexOf(Object o)
{
- return indexOfWithOffset(o, 0, _elements.length);
- }
-
- @Override
- public int indexOfWithOffset(Object o, int startingOffset, int endingOffset) {
if (withDummy)
{
if (o==null) return -1;
@@ -106,15 +101,15 @@ public int indexOfWithOffset(Object o, int startingOffset, int endingOffset) {
val = parse((String) o);
else
val = (Long)o;
- return Arrays.binarySearch(_elements, startingOffset, endingOffset, val);
+ return Arrays.binarySearch(_elements, 1, _elements.length, val);
} else
{
long val;
if (o instanceof String)
val = parse((String) o);
else
val = (Long)o;
- return Arrays.binarySearch(_elements, startingOffset, endingOffset, val);
+ return Arrays.binarySearch(_elements, val);
}
}
@@ -86,7 +86,8 @@ public short getPrimitiveValue(int index)
}
@Override
- public int indexOfWithOffset(Object o, int startingOffset, int endingOffset) {
+ public int indexOf(Object o)
+ {
if (withDummy)
{
if (o==null) return -1;
@@ -95,18 +96,17 @@ public int indexOfWithOffset(Object o, int startingOffset, int endingOffset) {
val = parse((String) o);
else
val = (Short)o;
- return Arrays.binarySearch(_elements, startingOffset, endingOffset, val);
+ return Arrays.binarySearch(_elements, 1, _elements.length, val);
} else
{
short val;
if (o instanceof String)
val = parse((String) o);
else
val = (Short)o;
- return Arrays.binarySearch(_elements, startingOffset, endingOffset, val);
+ return Arrays.binarySearch(_elements, val);
}
}
-
public int indexOf(Short val)
{
if (withDummy)
@@ -61,31 +61,28 @@ public String format(Object o) {
return (String)o;
}
- @Override
- public int indexOfWithOffset(Object o, int startingOffset, int endingOffset) {
- if (withDummy)
- {
- if (o == null) return -1;
-
- if (o.equals("")) {
+ @Override
+ public int indexOf(Object o)
+ {
+ if (withDummy)
+ {
+ if (o == null) return -1;
+
+ if (o.equals("")) {
if (_innerList.size() > 1 && "".equals(_innerList.get(1))) {
return 1;
} else if (_innerList.size() < 2) {
return -1;
- }
- }
- ArrayList<String> stringList = (ArrayList<String>) _innerList;
- List<String> sublist = stringList.subList(startingOffset, endingOffset);
- return Collections.binarySearch(sublist, (String)o);
- } else
- {
- ArrayList<String> stringList = (ArrayList<String>) _innerList;
- List<String> sublist = stringList.subList(startingOffset, endingOffset);
- return Collections.binarySearch(sublist, (String)o);
- }
- }
+ }
+ }
+ return Collections.binarySearch(((ArrayList<String>)_innerList), (String)o);
+ } else
+ {
+ return Collections.binarySearch(((ArrayList<String>)_innerList), (String)o);
+ }
+ }
- @Override
+ @Override
public void seal() {
((ArrayList<String>)_innerList).trimToSize();
}
@@ -104,18 +104,10 @@ public T getRawValue(int index){
public Comparable getComparableValue(int index){
return (Comparable) _innerList.get(index);
}
-
- public int indexOf(Object o){
- return indexOfWithOffset(o, 0, size());
- }
+ abstract public int indexOf(Object o);
public int indexOfWithOffset(Object value, int offset)
{
- return indexOfWithOffset(value, offset, size());
- }
-
- public int indexOfWithOffset(Object value, int startingOffset, int endingOffset)
- {
throw new IllegalStateException("not supported");
}

0 comments on commit db8685b

Please sign in to comment.