package net.ihiroky.niotty.buffer;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Iterator;

/**
 * @author Hiroki Itoh
 */
public class EncodeBufferGroup implements Iterable<EncodeBuffer> {

    private Deque<EncodeBuffer> group = new ArrayDeque<>();

    public void addLast(EncodeBuffer encodeBuffer) {
        group.addLast(encodeBuffer);
    }

    public void addFirst(EncodeBuffer encodeBuffer) {
        group.addFirst(encodeBuffer);
    }

    public EncodeBuffer pollFirst() {
        return group.pollFirst();
    }

    public EncodeBuffer pollLast() {
        return group.pollLast();
    }

    @Override
    public Iterator<EncodeBuffer> iterator() {
        return group.iterator();
    }
}

@@ -721,11 +721,197 @@
 );%0A    %7D
+%0A%0A    public int filledBytes() %7B%0A        int sum = 0;%0A        for (EncodeBuffer encodeBuffer : group) %7B%0A            sum += encodeBuffer.filledBytes();%0A        %7D%0A        return sum;%0A    %7D
 %0A%7D%0A

Add method to count filled bytes