<NME> GeoitemLayers.java
<BEF> package cgeo.geocaching.maps.mapsforge.v6.caches;

import cgeo.geocaching.enumerations.CoordinatesType;

import androidx.annotation.NonNull;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

import org.mapsforge.map.layer.Layer;

public class GeoitemLayers implements Collection<GeoitemLayer> {

    /**
     * ordered set of items to be displayed
    /**
     * ordered set of items to be displayed
     */
    private final HashMap<String, GeoitemLayer> geoitems = new LinkedHashMap<>();
    private final Set<String> cacheCodes = new HashSet<>();

    public synchronized Collection<String> getGeocodes() {
        return new ArrayList<>(geoitems.keySet());
    }

    public synchronized Collection<String> getCacheGeocodes() {
        return new ArrayList<>(cacheCodes);
    }

    public synchronized int getCacheCount() {
        return cacheCodes.size();
    }

    public synchronized GeoitemLayer getItem(final String itemCode) {
        return geoitems.get(itemCode);
    }

        return result;
    }

    private boolean addInternal(final GeoitemLayer geoitem) {
        return geoitems.put(geoitem.getItemCode(), geoitem) != null;
    }

    @Override
    public synchronized boolean add(final GeoitemLayer geoitem) {
        return addInternal(geoitem);
    }

    @Override
    public synchronized boolean addAll(@NonNull final Collection<? extends GeoitemLayer> geoitemsIn) {
        boolean result = true;
        for (final GeoitemLayer geoitem : geoitemsIn) {
            if (!this.addInternal(geoitem)) {
                result = false;
            }
        }
        return result;
    }

    @Override
    public synchronized void clear() {
        this.geoitems.clear();
    }

    @Override
    public synchronized boolean contains(final Object object) {
        return this.geoitems.containsValue(object);
    }

    @Override
    public synchronized boolean containsAll(@NonNull final Collection<?> items) {
        return this.geoitems.values().containsAll(items);
    }

    @Override
    public synchronized boolean isEmpty() {
        return this.geoitems.isEmpty();
    }

    @Override
    @NonNull
    public synchronized Iterator<GeoitemLayer> iterator() {
        return new ArrayList<>(this.geoitems.values()).iterator();
    }

    private boolean removeInternal(final Object object) {
        if (object instanceof GeoitemLayer) {
            final GeoitemLayer item = (GeoitemLayer) object;
            return this.geoitems.remove(item.getItem().getItemCode()) != null;
            final boolean result = this.geoitems.remove(item.getItem().getItemCode()) != null;
            if (result && item.getItem().getType() == CoordinatesType.CACHE) {
                cacheCodes.remove(item.getItemCode());
        return false;
    }

    @Override
    public synchronized boolean remove(final Object object) {
        return removeInternal(object);
    }

    @Override
    public synchronized boolean removeAll(@NonNull final Collection<?> items) {
        boolean result = true;
        for (final Object item : items) {
            if (!this.removeInternal(item)) {
                result = false;
            }
        }
        return result;
    }

    @Override
    public synchronized boolean retainAll(@NonNull final Collection<?> items) {

        return this.geoitems.values().retainAll(items);
    }

    @Override
    public synchronized int size() {

        return this.geoitems.size();
    }

    @Override
    @NonNull
    public synchronized Object[] toArray() {

        return this.geoitems.values().toArray();
    }

    @SuppressWarnings("hiding")
    @Override
    @NonNull
    public synchronized <GeoitemLayer> GeoitemLayer[] toArray(final GeoitemLayer[] array) {

        return this.geoitems.values().toArray(array);
    }

}
}

<MSG> Implement more appropriate interface and remove unused methods

<DFF> @@ -10,7 +10,7 @@ import java.util.LinkedHashMap;
 
 import org.mapsforge.map.layer.Layer;
 
-public class GeoitemLayers implements Collection<GeoitemLayer> {
+public class GeoitemLayers implements Iterable<GeoitemLayer> {
 
     /**
      * ordered set of items to be displayed
@@ -39,53 +39,21 @@ public class GeoitemLayers implements Collection<GeoitemLayer> {
         return result;
     }
 
-    private boolean addInternal(final GeoitemLayer geoitem) {
-        return geoitems.put(geoitem.getItemCode(), geoitem) != null;
-    }
-
-    @Override
     public synchronized boolean add(final GeoitemLayer geoitem) {
-        return addInternal(geoitem);
-    }
-
-    @Override
-    public synchronized boolean addAll(@NonNull final Collection<? extends GeoitemLayer> geoitemsIn) {
-        boolean result = true;
-        for (final GeoitemLayer geoitem : geoitemsIn) {
-            if (!this.addInternal(geoitem)) {
-                result = false;
-            }
-        }
-        return result;
+        return geoitems.put(geoitem.getItemCode(), geoitem) != null;
     }
 
-    @Override
     public synchronized void clear() {
         this.geoitems.clear();
     }
 
-    @Override
-    public synchronized boolean contains(final Object object) {
-        return this.geoitems.containsValue(object);
-    }
-
-    @Override
-    public synchronized boolean containsAll(@NonNull final Collection<?> items) {
-        return this.geoitems.values().containsAll(items);
-    }
-
-    @Override
-    public synchronized boolean isEmpty() {
-        return this.geoitems.isEmpty();
-    }
-
     @Override
     @NonNull
     public synchronized Iterator<GeoitemLayer> iterator() {
         return new ArrayList<>(this.geoitems.values()).iterator();
     }
 
-    private boolean removeInternal(final Object object) {
+    public synchronized boolean remove(final Object object) {
         if (object instanceof GeoitemLayer) {
             final GeoitemLayer item = (GeoitemLayer) object;
             return this.geoitems.remove(item.getItem().getItemCode()) != null;
@@ -95,47 +63,9 @@ public class GeoitemLayers implements Collection<GeoitemLayer> {
         return false;
     }
 
-    @Override
-    public synchronized boolean remove(final Object object) {
-        return removeInternal(object);
-    }
-
-    @Override
-    public synchronized boolean removeAll(@NonNull final Collection<?> items) {
-        boolean result = true;
-        for (final Object item : items) {
-            if (!this.removeInternal(item)) {
-                result = false;
-            }
-        }
-        return result;
-    }
-
-    @Override
-    public synchronized boolean retainAll(@NonNull final Collection<?> items) {
-
-        return this.geoitems.values().retainAll(items);
-    }
-
-    @Override
     public synchronized int size() {
 
         return this.geoitems.size();
     }
 
-    @Override
-    @NonNull
-    public synchronized Object[] toArray() {
-
-        return this.geoitems.values().toArray();
-    }
-
-    @SuppressWarnings("hiding")
-    @Override
-    @NonNull
-    public synchronized <GeoitemLayer> GeoitemLayer[] toArray(final GeoitemLayer[] array) {
-
-        return this.geoitems.values().toArray(array);
-    }
-
 }

Implement more appropriate interface and remove unused methods