getd_partial_key
| Definition: | object key = getd_partial_key(object pkey, integer tid=1, bool rev=false) |
| Description: | Retrieve the first key >= (or <= if rev is true) the specified partial key. |
| pwa/p2js: | Supported. |
| Comments: |
tid can be omitted, to use the default dictionary, or the result of a previous new_dict() call.
This routine is a "single-shot" variant of traverse_dict_partial_key(); obviously the latter must be used when you want to "carry on" in any way. As per getd(), this function can return the setd_default() value for non-existent keys (ie the specified key is past the end/start of file, or rather in this case the highest/lowest entry). In other words there is no equivalent of getd_index() here, other than by using traverse_dict_partial_key() and finding out that either rid was not invoked, or the first time it was invoked the key was already past anything of interest. |
| Example: |
setd("this",0)
setd("that",0)
setd("those",0)
?getd_partial_key("the") -- prints "this"
It is up to the calling program to decide whether "this" is of any use, when it does not actually start with the partial key, ie "the". |
| See Also: | getd, setd_default, getd_index, traverse_dict_partial_key |