    public CompositeSequence(Class<T> clazz, Sequence<? extends T>... sequences) {
        super(clazz);
        this.sequences = sequences.clone();
        this.startPositions = new int[sequences.length];
        int size = 0;
        int depth = 0;
        for (int i = 0, offset = 0; i < sequences.length; i++) {
            if (!sequences[i].getElementType().isAssignableFrom(clazz))
                throw new ClassCastException();
            startPositions[i] = offset;
            size += sequences[i].size();
            offset += sequences[i].size();
            depth = Math.max(depth, sequences[i].getDepth());
        }
        this.size = size;
        this.depth = depth + 1;
    }

    public CompositeSequence(Class<T> clazz, Sequence<? extends T>... sequences) {
        super(clazz);
        this.sequences = sequences.clone();
        this.startPositions = new int[sequences.length];
        int size = 0;
        int depth = 0;
        for (int i = 0, offset = 0; i < sequences.length; i++) {
            Class eClass = sequences[i].getElementType();
            if (!clazz.isAssignableFrom(eClass))
                throw new ClassCastException("cannot cast "+eClass.getName()
                                             +" segment to "+clazz.getName()+" sequence");
            startPositions[i] = offset;
            size += sequences[i].size();
            offset += sequences[i].size();
            depth = Math.max(depth, sequences[i].getDepth());
        }
        this.size = size;
        this.depth = depth + 1;
    }
