vigna / fastutil

fastutil extends the Java™ Collections Framework by providing type-specific maps, sets, lists and queues.
Apache License 2.0
1.74k stars 194 forks source link

Object2ObjectArrayMap should have all fields protected #285

Closed frajt closed 1 year ago

frajt commented 1 year ago

Hi,

any reason why Object2ObjectArrayMap has all fields as private? Both the Object2ObjectOpenHashMap and Object2ObjectMaps.Singleton for example have all fields defined as protected allowing to implement custom subclass and custom extensions if required. This way it is a bit inconsistent and causing trouble for us when implementing our custom Map iterator in a BitSet nextIndex()/keyAtIndex()/valueAtIndex() style. It fully eliminates creation of an iterator object when a map (or set) needs to be iterated. Especially for small Array based Maps/Sets its perfect fit but works nice on all open-adressing maps backuped by an indexable array. No need to create Iterator object, no need to mutate BasicEntry on each next() call - kind of no-gc iteration way.

Would it be possible to change it to protected?

Thanks, Michal

vigna commented 1 year ago

I just pushed the changes. They will be part of the next release.