@Override
        public boolean retainAll(Collection<?> collection) {
            int N = colGetSize();
            boolean changed = false;
            for (int i = 0; i < N; i++) {
                Object cur = colGetEntry(i, 1);
                if (!collection.contains(cur)) {
                    colRemoveAt(i);
                    i--;
                    N--;
                    changed = true;
                }
            }
            return changed;
        }
Helper for writing standard Java collection interfaces to a data
structure like {@link ArrayMap}.
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/util/collection/MapCollections.java