Index of the entry with this long name, or 0.
A linear walk over the registration array. A command line has tens of options, not thousands, and at that size a scan beats hashing while needing no map to allocate, copy or free.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(cli_t), | intent(in) | :: | this | |||
| character(len=*), | intent(in) | :: | name |
Long name to look for, without dashes. |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private | :: | i |
pure function cli_find(this, name) result(idx) !! Index of the entry with this long name, or 0. !! !! A linear walk over the registration array. A command line has tens of !! options, not thousands, and at that size a scan beats hashing while !! needing no map to allocate, copy or free. class(cli_t), intent(in) :: this character(len=*), intent(in) :: name !! Long name to look for, without dashes. integer(default_int) :: idx integer(default_int) :: i idx = 0_default_int do i = 1_default_int, this%count if (char(this%entries(i)%name) == name) then idx = i return end if end do end function cli_find