本文整理汇总了Java中com.rapidminer.example.Tools.isDefault方法的典型用法代码示例。如果您正苦于以下问题:Java Tools.isDefault方法的具体用法?Java Tools.isDefault怎么用?Java Tools.isDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.example.Tools
的用法示例。
在下文中一共展示了Tools.isDefault方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: set
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/** Sets the given data for the given index. */
@Override
protected void set(int index, double value, double defaultValue) {
if (Tools.isDefault(defaultValue, value)) {
data.remove(index);
} else {
data.put(index, value);
}
}
示例2: set
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/**
* Sets the value for the given row. Returns {@code true} if after this set the sparse chunk is
* too full, i.e. its density is bigger than
* {@link AutoColumnUtils#THRESHOLD_HIGH_SPARSITY_MAXIMAL_DENSITY}. Note that the density check only
* works if the total size was {@link #ensure}d before.
*
* @param row
* the row for which to set the value
* @param value
* the value to store
* @return {@code true} if the maximal density is reached
*/
public final boolean set(int row, double value) {
int index = getIndex(row);
if (Tools.isDefault(defaultValue, value)) {
// index not set, default value => do nothing
if (index < 0) {
return false;
}
// remove existing index
removeIndex(index);
return false;
}
boolean tooFull = false;
if (index < 0) {
// insert new index
// see Arrays.binarySearch
index = -index - 1;
insertIndex(index);
// check density
if (valueCount / (double) ensuredCount > AutoColumnUtils.THRESHOLD_HIGH_SPARSITY_MAXIMAL_DENSITY) {
tooFull = true;
}
}
// set index
indices[index] = row;
// set value in base column
setValue(index, value);
return tooFull;
}
示例3: set
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/** Sets the given data for the given index. */
@Override
protected void set(int index, double value, double defaultValue) {
if (Tools.isDefault(defaultValue, value))
data.remove(index);
else
data.put(index, value);
}
示例4: set
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/** Sets the given data for the given attribute. */
@Override
protected void set(int index, double value, double defaultValue) {
// first search if it is already available
// we need to replace the value
// return a negative int if the value is not in the array
// the list is ALWAYS sorted
int index1 = java.util.Arrays.binarySearch(x, index);
if (Tools.isDefault(defaultValue, value)) {
if (index1 >= 0) { // (old value != deflt) AND new is default -->
// remove entry from arrays
System.arraycopy(x, index1 + 1, x, index1, (counter - (index1 + 1)));
x[counter - 1] = Integer.MAX_VALUE;
removeValue(index1);
counter--;
}
} else {
if (index1 < 0) { // a new entry
if (counter >= x.length) { // need more space
int newlength = x.length + (x.length >> 1) + 1;
int[] y = new int[newlength];
System.arraycopy(x, 0, y, 0, x.length);
for (int i = x.length; i < y.length; i++) {
y[i] = Integer.MAX_VALUE;
}
x = y;
resizeValues(newlength);
}
// adds the new value at the end of the array
x[counter] = index;
setValue(counter, value);
// compare to the one before him
if ((counter > 0) && (index < x[counter - 1])) {
sort(0, x.length);
}
counter++;
} else { // replace existing value
setValue(index1, value);
}
}
}
示例5: set
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
@Override
protected void set(int index, double value, double defaultValue) {
assert (numberOfValues <= tableIndices.length);
assert (tableIndices.length == values.length);
int valueIndex = Arrays.binarySearch(tableIndices, 0, numberOfValues, index);
if (valueIndex > 0) {
// if index already has a value: test if new values is equal to defaultValue
if (Tools.isDefault(defaultValue, value)) {
// new value is default
if (valueIndex + 1 < values.length) {
// if it is not last: copy all subsequent one in front
System.arraycopy(values, valueIndex + 1, values, valueIndex, values.length - valueIndex - 1);
System.arraycopy(tableIndices, valueIndex + 1, tableIndices, valueIndex, values.length - valueIndex - 1);
}
numberOfValues--;
} else {
// old value must simply be overridden
values[valueIndex] = value;
}
} else if (!Tools.isDefault(defaultValue, value)) {
// index is unknown and value different from defaultValue, we have to insert it
int insertionIndex = -(valueIndex + 1);
if (numberOfValues == tableIndices.length) {
// no space left: enlarge array
double[] newValues = new double[values.length + (values.length >> 1) + 1];
int[] newTableIndices = new int[values.length + (values.length >> 1) + 1];
// copy the two halves before and after the insertion point
System.arraycopy(values, 0, newValues, 0, insertionIndex);
System.arraycopy(values, insertionIndex, newValues, insertionIndex + 1, numberOfValues - insertionIndex);
System.arraycopy(tableIndices, 0, newTableIndices, 0, insertionIndex);
System.arraycopy(tableIndices, insertionIndex, newTableIndices, insertionIndex + 1, numberOfValues
- insertionIndex);
values = newValues;
tableIndices = newTableIndices;
} else {
// enough space: shift subsequent arrays
System.arraycopy(values, insertionIndex, values, insertionIndex + 1, numberOfValues - insertionIndex);
System.arraycopy(tableIndices, insertionIndex, tableIndices, insertionIndex + 1, numberOfValues
- insertionIndex);
}
// finally setting value
tableIndices[insertionIndex] = index;
values[insertionIndex] = value;
// and increase counter
numberOfValues++;
}
}
示例6: writeDatum
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/**
* Writes a single datum with the given index. The data type is specified by the parameter
* columnType. If sparse is true, the value is prefixed by the given attributeIndex.
*/
public final void writeDatum(final double value, final int attributeIndex, final Attribute attribute,
final ColumnType columnType, final DataOutput out, final boolean sparse) throws IOException {
if (sparse) {
if (Tools.isDefault(attribute.getDefault(), value)) {
return;
} else {
out.writeInt(attributeIndex);
}
}
switch (columnType) {
case DOUBLE:
out.writeDouble(value);
break;
case INTEGER:
if (Double.isNaN(value)) {
out.writeInt(Integer.MIN_VALUE + 1);
out.writeBoolean(true);
} else {
out.writeInt((int) value);
if ((int) value == Integer.MIN_VALUE + 1) {
out.writeBoolean(false);
}
}
break;
// For the nominal values, we *can* use -1 to encode missings since all values are
// guaranteed to be non-negative
case NOMINAL_BYTE:
if (Double.isNaN(value)) {
out.writeByte(-1);
} else {
out.writeByte((byte) value);
}
break;
case NOMINAL_INTEGER:
if (Double.isNaN(value)) {
out.writeInt(-1);
} else {
out.writeInt((int) value);
}
break;
case NOMINAL_SHORT:
if (Double.isNaN(value)) {
out.writeShort(-1);
} else {
out.writeShort((short) value);
}
break;
default:
// cannot happen
throw new RuntimeException("Illegal type: " + columnType);
}
}
示例7: set
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/** Sets the given data for the given attribute. */
@Override
protected synchronized void set(int index, double value, double defaultValue) {
// first search if it is already available
// we need to replace the value
// return a negative int if the value is not in the array
// the list is ALWAYS sorted
int index1 = java.util.Arrays.binarySearch(x, index);
if (Tools.isDefault(defaultValue, value)) {
if (index1 >= 0) { // (old value != deflt) AND new is default -->
// remove entry from arrays
System.arraycopy(x, index1 + 1, x, index1, (counter - (index1 + 1)));
x[counter - 1] = Integer.MAX_VALUE;
removeValue(index1);
counter--;
}
} else {
if (index1 < 0) { // a new entry
if (counter >= x.length) { // need more space
int newlength = x.length + (x.length >> 1) + 1;
int[] y = new int[newlength];
System.arraycopy(x, 0, y, 0, x.length);
for (int i = x.length; i < y.length; i++) {
y[i] = Integer.MAX_VALUE;
}
x = y;
resizeValues(newlength);
}
// adds the new value at the end of the array
x[counter] = index;
setValue(counter, value);
// compare to the one before him
if ((counter > 0) && (index < x[counter - 1])) {
sort(0, x.length);
}
counter++;
} else { // replace existing value
setValue(index1, value);
}
}
}
示例8: set
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/** Sets the given data for the given attribute. */
@Override
protected void set(int index, double value, double defaultValue) {
// first search if it is already available
// we need to replace the value
// return a negative int if the value is not in the array
// the list is ALWAYS sorted
int index1 = java.util.Arrays.binarySearch(x, index);
if (Tools.isDefault(defaultValue, value)) {
if (index1 >= 0) { // (old value != deflt) AND new is default -->
// remove entry from arrays
System.arraycopy(x, index1 + 1, x, index1, (counter - (index1 + 1)));
x[counter - 1] = Integer.MAX_VALUE;
removeValue(index1);
counter--;
}
} else {
if (index1 < 0) { // a new entry
if (counter >= x.length) { // need more space
int newlength = x.length + (x.length >> 1) + 1;
int[] y = new int[newlength];
System.arraycopy(x, 0, y, 0, x.length);
for (int i = x.length; i < y.length; i++)
y[i] = Integer.MAX_VALUE;
x = y;
resizeValues(newlength);
}
// adds the new value at the end of the array
x[counter] = index;
setValue(counter, value);
// compare to the one before him
if ((counter > 0) && (index < x[counter - 1])) {
sort(0, x.length);
}
counter++;
} else { // replace existing value
setValue(index1, value);
}
}
}
示例9: set
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
@Override
protected void set(int index, double value, double defaultValue) {
assert(numberOfValues <= tableIndices.length);
assert(tableIndices.length == values.length);
int valueIndex = Arrays.binarySearch(tableIndices, 0, numberOfValues, index);
if (valueIndex > 0) {
// if index already has a value: test if new values is equal to defaultValue
if (Tools.isDefault(defaultValue, value)) {
// new value is default
if (valueIndex + 1 < values.length) {
// if it is not last: copy all subsequent one in front
System.arraycopy(values, valueIndex + 1, values, valueIndex, values.length - valueIndex - 1);
System.arraycopy(tableIndices, valueIndex + 1, tableIndices, valueIndex, values.length - valueIndex - 1);
}
numberOfValues--;
} else {
// old value must simply be overridden
values[valueIndex] = value;
}
} else if (!Tools.isDefault(defaultValue, value)) {
// index is unknown and value different from defaultValue, we have to insert it
int insertionIndex = - (valueIndex + 1);
if (numberOfValues == tableIndices.length) {
// no space left: enlarge array
double[] newValues = new double[values.length + (values.length >> 1) + 1];
int[] newTableIndices = new int[values.length + (values.length >> 1) + 1];
// copy the two halves before and after the insertion point
System.arraycopy(values, 0, newValues, 0, insertionIndex);
System.arraycopy(values, insertionIndex, newValues, insertionIndex + 1, numberOfValues - insertionIndex);
System.arraycopy(tableIndices, 0, newTableIndices, 0, insertionIndex);
System.arraycopy(tableIndices, insertionIndex, newTableIndices, insertionIndex + 1, numberOfValues - insertionIndex);
values = newValues;
tableIndices = newTableIndices;
} else {
// enough space: shift subsequent arrays
System.arraycopy(values, insertionIndex, values, insertionIndex + 1, numberOfValues - insertionIndex);
System.arraycopy(tableIndices, insertionIndex, tableIndices, insertionIndex + 1, numberOfValues - insertionIndex);
}
// finally setting value
tableIndices[insertionIndex] = index;
values[insertionIndex] = value;
// and increase counter
numberOfValues++;
}
}
示例10: writeDatum
import com.rapidminer.example.Tools; //导入方法依赖的package包/类
/** Writes a single datum with the given index. The data type is specified by the parameter columnType.
* If sparse is true, the value is prefixed by the given attributeIndex. */
public final void writeDatum(double value, int attributeIndex, Attribute attribute, ColumnType columnType, DataOutput out, boolean sparse) throws IOException {
if (sparse) {
if (Tools.isDefault(attribute.getDefault(), value)) {
return;
} else {
out.writeInt(attributeIndex);
}
}
switch (columnType) {
case DOUBLE:
out.writeDouble(value);
break;
case INTEGER:
if (Double.isNaN(value)) {
out.writeInt(Integer.MIN_VALUE+1);
out.writeBoolean(true);
} else {
out.writeInt((int)value);
if ((int)value == Integer.MIN_VALUE+1) {
out.writeBoolean(false);
}
}
break;
// For the nominal values, we *can* use -1 to encode missings since all values are guaranteed to be non-negative
case NOMINAL_BYTE:
if (Double.isNaN(value)) {
out.writeByte(-1);
} else {
out.writeByte((byte)value);
}
break;
case NOMINAL_INTEGER:
if (Double.isNaN(value)) {
out.writeInt(-1);
} else {
out.writeInt((int)value);
}
break;
case NOMINAL_SHORT:
if (Double.isNaN(value)) {
out.writeShort(-1);
} else {
out.writeShort((short)value);
}
break;
default:
// cannot happen
throw new RuntimeException("Illegal type: "+columnType);
}
}