http://www.perlmonks.org?node_id=289376


in reply to Re: Any Point in Uploading Tie::SortedHash
in thread Any Point in Uploading Tie::SortedHash

Abigail,
My verbiage was incorrect. The code is a hybrid as you describe. The rebuild does not happen when a key is deleted, value is changed, etc. Only a flag is set that is checked when FIRSTKEY is called. A rebuild only happens under those circumstances.

In reference to deleting an array element taking time in linear proportion to the size of the array, no I was not aware of this. The two alternatives I can think of are:

  • Set the CHANGED flag and rebuild if FIRSTKEY is ever called again
  • Use more memory and delay the delete(s) until FIRSTKEY is called again. If in the interim the hash is modified, the rebuild would occur and the delete(s) would be forgotten. If FIRSTKEY was never called again, they would also be forgotten (albeit using some memory).

    Do you see a clear way to go?

    Cheers - L~R