Class SafeHashMap.KeySet

    • Constructor Detail

      • KeySet

        protected KeySet()
    • Method Detail

      • size

        public int size()
        Determine the number of keys in the Set.
        Specified by:
        size in interface Collection<K>
        Specified by:
        size in interface Set<K>
        Specified by:
        size in class AbstractCollection<K>
        Returns:
        the number of keys in the Set, which is the same as the number of entries in the underlying Map
      • remove

        public boolean remove​(Object o)
        Removes the specified element from this Set of keys if it is present by removing the associated entry from the underlying Map.
        Specified by:
        remove in interface Collection<K>
        Specified by:
        remove in interface Set<K>
        Overrides:
        remove in class AbstractCollection<K>
        Parameters:
        o - object to be removed from this set, if present
        Returns:
        true if the set contained the specified element
      • clear

        public void clear()
        Removes all of the elements from this set of Keys by clearing the underlying Map.
        Specified by:
        clear in interface Collection<K>
        Specified by:
        clear in interface Set<K>
        Overrides:
        clear in class AbstractCollection<K>
      • toArray

        public <T> T[] toArray​(T[] a)
        Returns an array with a runtime type is that of the specified array and that contains all of the keys in this Set. If the Set fits in the specified array, it is returned there = in. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this collection.

        If the Set fits in the specified array with room to spare (i.e., the array has more elements than the Set), the element in the array immediately following the end of the Set is set to null. This is useful in determining the length of the Set only if the caller knows that the Set does not contain any null keys.)

        Specified by:
        toArray in interface Collection<K>
        Specified by:
        toArray in interface Set<K>
        Overrides:
        toArray in class AbstractCollection<K>
        Parameters:
        a - the array into which the elements of the Set are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose
        Returns:
        an array containing the elements of the Set
        Throws:
        ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this Set of keys