K - the key typeV - the value typepublic static class ImmutableMap.KeySet<K,V> extends ImmutableCollectionBase<ImmutableMapEntry<K,V>,K> implements Set<K>
Set interface to provide a view of the keys in the ImmutableMap. It makes
use of the same underlying array, but returns only the key portion of the ImmutableMapEntry.| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Object o)
Test whether the set contains an element equal to the specified object (which may be
null). |
boolean |
equals(Object other)
Compares the specified object with this set for equality.
|
K |
get(int index)
Get the key at the specified index.
|
int |
hashCode()
Returns the hash code value for this set.
|
Iterator<K> |
iterator()
Return an
Iterator over the set. |
Object[] |
toArray()
Create a copy of the set in an array.
|
<T> T[] |
toArray(T[] a)
Return a copy of the set, either in the supplied array (if it fits) or in a new array of the specified type.
|
add, addAll, containsAll, remove, removeAll, retainAll, toStringclear, isEmpty, sizeclone, finalize, getClass, notify, notifyAll, wait, wait, waitadd, addAll, clear, containsAll, isEmpty, remove, removeAll, retainAll, size, spliteratorparallelStream, removeIf, streampublic boolean contains(Object o)
null).public Object[] toArray()
public <T> T[] toArray(T[] a)
toArray in interface Collection<K>toArray in interface Set<K>T - the type of the destination array itemsa - the destination arrayArrayStoreException - if the keys in the map can't be stored in the destination arraypublic boolean equals(Object other)
true if the specified object is
also a set, the two sets have the same size, and every member of the specified set is contained in this set
(or equivalently, every member of this set is contained in the specified set). This definition ensures that
the equals method works properly across different implementations of the set interface.public int hashCode()
null element is defined to be zero. This
ensures that s1.equals(s2) implies that s1.hashCode() == s2.hashCode() for any two sets
s1 and s2, as required by the general contract of Object.hashCode().public K get(int index)
Set interface, but it allows
iteration over the entries of a map without needing to instantiate an Iterator.
index - the indexIndexOutOfBoundsException - if the index is less than 0 or greater than the length of the listCopyright © 2023. All rights reserved.