Add a method to help with filter/field iteration

- Add explanatory comments
Yes, I as far as I know that's correct -- the two exceptions are duplicate field names across info fields/format fields/filters, and manually-specified field indices via IDX=. Did not mean more than this. 

When htslib assigns field indices for header fields in `bcf_hdr_register_hrec()` (vcf.c lines 442-458) it checks first if the field name is already present in the table, and if it is it re-uses the same index. Otherwise, it assigns the field the next available index, unless IDX= was specified, in which case it uses the specified index:

    if ( !ret )
    {
        // already present
        free(str);
        if ( kh_val(d, k).hrec[info&0xf] ) return 0;
        kh_val(d, k).info[info&0xf] = info;
        kh_val(d, k).hrec[info&0xf] = hrec;
        return 1;
    }
    kh_val(d, k) = bcf_idinfo_def;
    kh_val(d, k).info[info&0xf] = info;
    kh_val(d, k).hrec[info&0xf] = hrec;
    kh_val(d, k).id = idx==-1 ? kh_size(d) - 1 : idx;

Then, in `bcf_hdr_sync()` it finds the largest index, and uses that to resize the id table if necessary, which determines the value of `m_header->n[BCF_DT_ID]` that your new function is returning:

        for (k=kh_begin(d); k<kh_end(d); k++)
        {
            if (!kh_exist(d,k)) continue;
            if ( max_id < kh_val(d,k).id ) max_id = kh_val(d,k).id;
        }
        if ( max_id >= h->n[i] )
        {
            h->id[i] = (bcf_idpair_t*)realloc(h->id[i], (max_id+1)*sizeof(bcf_idpair_t));