    /*
     *  call-seq:
     *     term_doc_enum.each {|doc_id, freq| do_something() } -> doc_count
     *
     *  Iterate through the documents and document frequencies in the
     *  +term_doc_enum+.
     *
     *  NOTE: this method can only be called once after each seek. If you need to
     *  call +#each+ again then you should call +#seek+ again too.
     */
    static VALUE
    frb_tde_each(VALUE self)
    {
        int doc_cnt = 0;
        TermDocEnum *tde = (TermDocEnum *)DATA_PTR(self);
        VALUE vals = rb_ary_new2(2);
        rb_ary_store(vals, 0, Qnil);
        rb_ary_store(vals, 1, Qnil);

        while (tde->next(tde)) {
            doc_cnt++;
            RARRAY_PTR(vals)[0] = INT2FIX(tde->doc_num(tde));
            RARRAY_PTR(vals)[1] = INT2FIX(tde->freq(tde));
            rb_yield(vals);

        }
        return INT2FIX(doc_cnt);
    }