@Override public StringDatasetBase setBy1DIndex(final Object obj, final Dataset index) { if (obj instanceof Dataset) { final Dataset ds = (Dataset) obj; if (index.getSize() != ds.getSize()) { throw new IllegalArgumentException( "Number of items in index dataset does not match number of items in dataset"); } final IndexIterator oiter = ds.getIterator(); final IntegerIterator iter = new IntegerIterator(index, size); while (iter.hasNext() && oiter.hasNext()) { data[iter.index] = ds.getStringAbs(oiter.index); // GET_ELEMENT_WITH_CAST } } else { final String dv = obj.toString(); // PRIM_TYPE // FROM_OBJECT IntegerIterator iter = new IntegerIterator(index, size); while (iter.hasNext()) { data[iter.index] = dv; } } setDirty(); return this; }
@Override public CompoundIntegerDataset setByIndex(final Object o, IntegerDataset index) { if (o instanceof AbstractDataset) { AbstractDataset ds = (AbstractDataset) o; if (index.getSize() != ds.getSize()) { throw new IllegalArgumentException( "Number of true items in selection does not match number of items in dataset"); } IndexIterator oiter = ds.getIterator(); final IntegerIterator iter = new IntegerIterator(index, size, isize); if (ds instanceof AbstractCompoundDataset) { if (isize != ds.getElementsPerItem()) { throw new IllegalArgumentException("Input dataset is not compatible with slice"); } while (iter.hasNext() && oiter.hasNext()) { for (int i = 0; i < isize; i++) data[iter.index + i] = (int) ds.getElementLongAbs(oiter.index + i); // GET_ELEMENT_WITH_CAST } } else { while (iter.hasNext() && oiter.hasNext()) { data[iter.index] = (int) ds.getElementLongAbs(oiter.index); // GET_ELEMENT_WITH_CAST for (int i = 1; i < isize; i++) data[iter.index + i] = 0; } } } else { try { final int[] vr = toIntegerArray(o, isize); // PRIM_TYPE // CLASS_TYPE final IntegerIterator iter = new IntegerIterator(index, size, isize); while (iter.hasNext()) { for (int i = 0; i < isize; i++) data[iter.index + i] = vr[i]; } } catch (IllegalArgumentException e) { throw new IllegalArgumentException("Object for setting is not a dataset or number"); } } return this; }