public PreSequence sparse(Object e) {
Object[] ret;
- if (o.length <= 1) ret = o;
- else {
+ boolean[] drops;
+ if (o.length <= 1) {
+ ret = o;
+ drops = new boolean[this.drops.length];
+ System.arraycopy(this.drops, 0, drops, 0, this.drops.length);
+ } else {
ret = new Object[o.length * 2 - 1];
+ drops = new boolean[o.length * 2 - 1];
for(int i=0; i<o.length; i++) {
Object oi = o[i];
ret[i*2] = oi;
- if (i*2+1<ret.length) ret[i*2+1] = new MyDrop(e);
+ drops[i*2] = this.drops[i];
+ if (i*2+1<ret.length) {
+ ret[i*2+1] = new MyDrop(e);
+ drops[i*2+1] = true;
+ }
}
}
- PreSequence p = new PreSequence(ret, tag);
+ PreSequence p = new PreSequence(ret, tag, drops);
p.not.addAll(not);
p.and.addAll(and);
return p;
public PreSequence not(Sequence s) { not.add(s); return this; }
public PreSequence and(Sequence s) { and.add(s); return this; }
+ boolean[] drops = null;
public PreSequence(Object o) { this(new Object[] { o }, null); }
public PreSequence(Object[] o) { this(o, null); }
- public PreSequence(Object[] o, String tag) { this.o = o; this.tag = tag; }
+ public PreSequence(Object[] o, String tag) { this(o, tag, null); }
+ public PreSequence(Object[] o, String tag, boolean[] drops) {
+ this.o = o;
+ this.tag = tag;
+ this.drops = drops==null ? new boolean[o.length] : drops;
+ }
public Union buildUnion() {
Union u = new Union("???");
HashSet<Sequence> set = new HashSet<Sequence>();
Element[] o2 = o==null ? new Element[0] : new Element[o.length];
int nonDrop = 0;
- boolean[] drops = null;
if (o != null) {
- drops = new boolean[o.length];
int j = 0;
for(int i=0; i<o.length; i++) {
Object oi = o[i];