public StringTuple(String s){ this(s, stringToItems(s)); }
public StringTuple insert(int index, String value) throws IndexOutOfBoundsException{ if( index < 0 || index >= items.size()) throw new IndexOutOfBoundsException(); List<String> copy = stringToItems(repr); copy.add(index, value); String modifiedRepr = joinList(" ", copy); return new StringTuple(modifiedRepr, copy); }
public StringTuple remove(int index) throws IndexOutOfBoundsException{ if( index < 0 || index >= items.size()) throw new IndexOutOfBoundsException(); List<String> copy = stringToItems(repr); copy.remove(index); String modifiedRepr = joinList(" ", copy); return new StringTuple(modifiedRepr, copy); }
public StringTuple modify(int index, ModifierFn fn) throws IndexOutOfBoundsException{ if( index < 0 || index >= items.size()) throw new IndexOutOfBoundsException(); List<String> copy = stringToItems(repr); copy.set(index, fn.modify(items.get(index))); String modifiedRepr = joinList(" ", copy); return new StringTuple(modifiedRepr, copy); }