class SeriesTruncator {

    public static <T> SeriesTruncator<T> create(Series<T> series, int maxSize) {

        if (maxSize < 0) {
            maxSize = 0;
        }

        int h = series.size();
        if (h <= maxSize) {
            return new SeriesTruncator<>(series, false, h, 0);
        }

        int head = maxSize / 2 + maxSize % 2;
        int tail = maxSize - head;
        return new SeriesTruncator<>(series, true, head, tail);
    }

    private  SeriesTruncator(Series<T> series, boolean truncated, int head, int tail);

}