c73d43c2144864a0148f7165ff289cfecf0e290e
The algorithms for removeAll, retainAll and removeIf were almost identical. The main difference was, that removeIf calls a lambda, whereas removeAll and retainAll executed the check directly. Both methods call indexOf on an IntList, which easily outweighs the extra cost of the lambda. It makes sense to consolidate and remove the duplicated code. I ran a few benchmarks with different list sizes before the replacement. The results are not as clear as I would have liked. In some cases, especially for short lists, the special implementations of removeAll/retainAll were up to 10% faster. In other situations I saw 50% difference the one day, but could not reproduce those results a day later. This leads me to believe, that my test setup is not trustworthy. That means I stay with what I now. The code is identical with one tiny difference. And that difference shouldn't matter, because indexOf is much more expensive.
Java collections for primitives (currently only int) released under MIT license.
IntList is an implementation of a list to store primitive integers. You can add, insert, replace and remove elements in the list. The ints are stored in an int array and the class takes care of growing the array as needed. You can trim the list to reduce the memory overhead.
Languages
Java
99.9%
Shell
0.1%