Class Int2ObjectHashMap.KeySet

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.Integer>, java.util.Collection<java.lang.Integer>, java.util.Set<java.lang.Integer>
    Enclosing class:
    Int2ObjectHashMap<V>

    public final class Int2ObjectHashMap.KeySet
    extends java.util.AbstractSet<java.lang.Integer>
    Set of keys which supports optionally cached iterators to avoid allocation.
    • Constructor Summary

      Constructors 
      Constructor Description
      KeySet()
      Create a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      boolean contains​(int key)
      Checks if the key is contained in the map.
      boolean contains​(java.lang.Object o)
      Int2ObjectHashMap.KeyIterator iterator()
      boolean remove​(int key)
      Removes key and the corresponding value from the map.
      boolean remove​(java.lang.Object o)
      boolean removeIfInt​(java.util.function.IntPredicate filter)
      Removes all the elements of this collection that satisfy the given predicate.
      int size()
      • Methods inherited from class java.util.AbstractSet

        equals, hashCode, removeAll
      • Methods inherited from class java.util.AbstractCollection

        add, addAll, containsAll, isEmpty, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream, toArray
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.Set

        add, addAll, containsAll, isEmpty, retainAll, spliterator, toArray, toArray
    • Constructor Detail

      • KeySet

        public KeySet()
        Create a new instance.
    • Method Detail

      • iterator

        public Int2ObjectHashMap.KeyIterator iterator()
        Specified by:
        iterator in interface java.util.Collection<java.lang.Integer>
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Integer>
        Specified by:
        iterator in interface java.util.Set<java.lang.Integer>
        Specified by:
        iterator in class java.util.AbstractCollection<java.lang.Integer>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<java.lang.Integer>
        Specified by:
        size in interface java.util.Set<java.lang.Integer>
        Specified by:
        size in class java.util.AbstractCollection<java.lang.Integer>
      • contains

        public boolean contains​(java.lang.Object o)
        Specified by:
        contains in interface java.util.Collection<java.lang.Integer>
        Specified by:
        contains in interface java.util.Set<java.lang.Integer>
        Overrides:
        contains in class java.util.AbstractCollection<java.lang.Integer>
      • contains

        public boolean contains​(int key)
        Checks if the key is contained in the map.
        Parameters:
        key - to check.
        Returns:
        true if the key is contained in the map.
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<java.lang.Integer>
        Specified by:
        remove in interface java.util.Set<java.lang.Integer>
        Overrides:
        remove in class java.util.AbstractCollection<java.lang.Integer>
      • remove

        public boolean remove​(int key)
        Removes key and the corresponding value from the map.
        Parameters:
        key - to be removed.
        Returns:
        true if the mapping was removed.
      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Collection<java.lang.Integer>
        Specified by:
        clear in interface java.util.Set<java.lang.Integer>
        Overrides:
        clear in class java.util.AbstractCollection<java.lang.Integer>
      • removeIfInt

        public boolean removeIfInt​(java.util.function.IntPredicate filter)
        Removes all the elements of this collection that satisfy the given predicate.

        NB: Renamed from removeIf to avoid overloading on parameter types of lambda expression, which doesn't play well with type inference in lambda expressions.

        Parameters:
        filter - a predicate to apply.
        Returns:
        true if at least one key was removed.