@Override
    public Iterator<T> iterator() {
        return new Iterator<T>() {
            int x, y;
            int i;
            @Override
            public boolean hasNext() {
                int tmpi = i, tmpx = x, tmpy = y;
                while(tmpi >= bins[tmpy][tmpx].size()){
                    if(tmpx+1 < bins[0].length){
                        tmpx++;
                        tmpi = 0;
                    }else if(tmpy+1 < bins.length){
                        tmpy++;
                        tmpx = 0;
                        tmpi = 0;
                    }else{
                        return false;
                    }
                }
                return true;
            }

            @Override
            public T next() {
                while(i >= bins[y][x].size()){
                    if(x+1 < bins[0].length){
                        x++;
                        i = 0;
                    }else if(y+1 < bins.length){
                        y++;
                        x = 0;
                        i = 0;
                    }else{
                        return null;
                    }
                }
                return bins[y][x].get(i++);
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }
        };
    }