public Iterator<Compound> col_wise() {
        
        return new Iterator<Compound>() {

            int y = 0;
            int x = 0;
            int idx = 0;
            
            public boolean hasNext() {
                if ((x == cols-1) && (y < rows-1)) {
                    x = 0;
                }
                return true;
            }

            public Compound next() {
                idx++;
                return get(x,y);
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }