Fixes and improvements to IntObjectHashMap

- Rewrite with linear probing, no state array, compaction at cleanup
- Optimize keys() and values() to not use reflection
- Optimize hashCode() and equals() for efficient iteration
- Fixed equals() to not return true for equals(null)
- Optimize iterator to not allocate new Entry at each next()
- Added toString()
- Added some new unit tests
Ah right... Maybe add a comment to make it clear why the null check is done. Just to be sure we not refactor it later

> Am 20.07.2014 um 17:21 schrieb Osvaldo Pinali Doederlein <notifications@github.com>:
> 
> In common/src/main/java/io/netty/util/collection/IntObjectHashMap.java:
> 
> > @@ -212,10 +183,9 @@ public boolean containsKey(int key) {
> >  
> >      @Override
> >      public boolean containsValue(V value) {
> > -        int i = -1;
> > -        while ((i = nextEntryIndex(i + 1)) >= 0) {
> > -            V next = values[i];
> > -            if (value == next || value != null && value.equals(next)) {
> > +        V v = setValue(value);
> > +        for (int i = 0; i < values.length; ++i) {
> > +            if (values[i] != null && values[i].equals(v)) {
> This is a very low-level optimization: nulls are expected to be very common (at least 50% of all slots even in a "full" map with the default load factor 0.5), so I fast-path this case before making any invocation, will be faster even if the equals call is inlined (which I don't expect to happen, in the general case it's a megamorphic call since you can put any ind of object in the map).
> 
> —
> Reply to this email directly or view it on GitHub.