X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=libcitadel%2Flib%2Fhash.c;fp=libcitadel%2Flib%2Fhash.c;h=0eedcab41c3850fd35746079009842e8a97050d3;hp=38d780ed4f4695ace5a61a24dda0f9b02ca85a28;hb=101a56a24149e797b4f8ae555f9aa004cb5f446d;hpb=1dcea0c8dff75cab9b7fbad51dae4cb300c6dc52 diff --git a/libcitadel/lib/hash.c b/libcitadel/lib/hash.c index 38d780ed4..0eedcab41 100644 --- a/libcitadel/lib/hash.c +++ b/libcitadel/lib/hash.c @@ -809,6 +809,30 @@ HashPos *GetNewHashPos(const HashList *Hash, int StepWidth) return Ret; } +/** + * @ingroup HashListAccess + * @brief resets a hash-linear iterator object + * @param Hash the list we reference + * @param StepWidth in which step width should we iterate? + * @param it the iterator object to manipulate + * If negative, the last position matching the + * step-raster is provided. + * @return the hash iterator + */ +void RewindHashPos(const HashList *Hash, HashPos *it, int StepWidth) +{ + if (StepWidth != 0) + it->StepWidth = StepWidth; + else + it->StepWidth = 1; + if (it->StepWidth < 0) { + it->Position = Hash->nLookupTableItems - 1; + } + else { + it->Position = 0; + } +} + /** * @ingroup HashListAccess * @brief Set iterator object to point to key. If not found, don't change iterator