kyren / hashlink

An updated version of linked-hash-map and friends
Apache License 2.0
98 stars 18 forks source link

feat: retain with inserting order #11

Closed quake closed 2 years ago

quake commented 3 years ago

resolve https://github.com/kyren/hashlink/issues/10

kyren commented 2 years ago

I'm so sorry that I've been sitting on this, I'm finally coming back into open source work after a hiatus.

After thinking about this, I'm not sure I like the extra hash lookup in retain or the fact that retain now has to have an extra bound on Hash and Eq. I think I'd rather just document that retain visits values in an arbitrary order. If it was truly needed, I would be more okay with adding a retain_ordered method or something that has the extra ordered behavior. I don't think this is an obviously better implementation of retain as it is, and I'd rather err on the side of obviousness.

quake commented 2 years ago

@kyren I have updated pr according to your review comment, please review again, thanks.