X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=libcitadel%2Flib%2Fhash.c;h=0eedcab41c3850fd35746079009842e8a97050d3;hb=101a56a24149e797b4f8ae555f9aa004cb5f446d;hp=740c0dd618a8ca61347514cd9bab4844ca4db3f6;hpb=ee02c153858193ccae3596f0ab2baede8aa85260;p=citadel.git diff --git a/libcitadel/lib/hash.c b/libcitadel/lib/hash.c index 740c0dd61..0eedcab41 100644 --- a/libcitadel/lib/hash.c +++ b/libcitadel/lib/hash.c @@ -788,7 +788,7 @@ int GetHashKeys(HashList *Hash, char ***List) * step-raster is provided. * @return the hash iterator */ -HashPos *GetNewHashPos(HashList *Hash, int StepWidth) +HashPos *GetNewHashPos(const HashList *Hash, int StepWidth) { HashPos *Ret; @@ -809,6 +809,30 @@ HashPos *GetNewHashPos(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 @@ -940,7 +964,7 @@ void DeleteHashPos(HashPos **DelMe) * @param Data returns the Data found at HashPos * @return whether the item was found or not. */ -int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, const char **HashKey, void **Data) +int GetNextHashPos(const HashList *Hash, HashPos *At, long *HKLen, const char **HashKey, void **Data) { long PayloadPos;