Package org.apache.hadoop.util
Interface GSet<K,E extends K>
- Type Parameters:
K- The type of the keys.E- The type of the elements, which must be a subclass of the keys.
- All Superinterfaces:
Iterable<E>
- All Known Implementing Classes:
GSetByHashMap,LightWeightCache,LightWeightGSet,LightWeightResizableGSet
A
GSet is set,
which supports the get(Object) operation.
The get(Object) operation uses a key to lookup an element.
Null element is not supported.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear the set.booleanDoes this set contain an element corresponding to the given key?Return the stored element which is equal to the given key.Add/replace an element.Remove the element corresponding to the given key.intsize()values()Returns aCollectionview of the values contained in this set.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Field Details
-
LOG
static final org.slf4j.Logger LOG
-
-
Method Details
-
size
int size()- Returns:
- The size of this set.
-
contains
Does this set contain an element corresponding to the given key?- Parameters:
key- The given key.- Returns:
- true if the given key equals to a stored element. Otherwise, return false.
- Throws:
NullPointerException- if key == null.
-
get
Return the stored element which is equal to the given key. This operation is similar toMap.get(Object).- Parameters:
key- The given key.- Returns:
- The stored element if it exists. Otherwise, return null.
- Throws:
NullPointerException- if key == null.
-
put
Add/replace an element. If the element does not exist, add it to the set. Otherwise, replace the existing element. Note that this operation is similar toMap.put(Object, Object)but is different fromSet.add(Object)which does not replace the existing element if there is any.- Parameters:
element- The element being put.- Returns:
- the previous stored element if there is any. Otherwise, return null.
- Throws:
NullPointerException- if element == null.
-
remove
Remove the element corresponding to the given key. This operation is similar toMap.remove(Object).- Parameters:
key- The key of the element being removed.- Returns:
- If such element exists, return it. Otherwise, return null.
- Throws:
NullPointerException- if key == null.
-
clear
void clear()Clear the set. -
values
Collection<E> values()Returns aCollectionview of the values contained in this set. The collection is backed by the set, so changes to the set are reflected in the collection, and vice-versa.- Returns:
- the collection of values.
-