/** * Copyright (c): Uwe Schmidt, FH Wedel * * You may study, modify and distribute this source code * FOR NON-COMMERCIAL PURPOSES ONLY. * This copyright message has to remain unchanged. * * Note that this document is provided 'as is', * WITHOUT WARRANTY of any kind either expressed or implied. */ /** * * successive double elements are flitered out * 0 0 1 2 2 1 0 0 0 --> 0 1 2 1 0 */ //-------------------- public class Unique extends Sequence { private long last; private Sequence s; public Unique(Sequence s) { this.s = s; this.last = s.next(); } public long next() { long res = last; while ( (last = s.next()) == res ); return res; } } //--------------------