Add new split functions

This commit is contained in:
altrisi committed 2021-01-11 19:46:39 +01:00
1 parent f3f8c689a8
commit 49ffa4f109
5 files changed
+52 -16

No files matched your search

@@ -347,6 +347,24 @@ public class ListValue extends AbstractListValue implements ContainerValueInterf
return new ListValue((Collection<? extends Value>) getItems().subList(from, to));
}
@Override
public Value split(Value delimiter) {
ListValue result = new ListValue();
int startIndex = 0;
int index = 0;
for (Value val : this.items)
{
index++;
if (val.equals(delimiter))
{
result.items.add(ListValue.wrap(this.items.subList(startIndex, index-1)));
startIndex = index;
}
}
result.items.add(ListValue.wrap(this.items.subList(startIndex, length())));
return result;
}
@Override
public double readDoubleNumber()
{