org.apache.hadoop.hdfs.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, LightWeightGSet

@InterfaceAudience.Private
public interface GSet<K,E extends K>
extends Iterable<E>

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.


Method Summary
 boolean contains(K key)
          Does this set contain an element corresponding to the given key?
 E get(K key)
          Return the stored element which is equal to the given key.
 E put(E element)
          Add/replace an element.
 E remove(K key)
          Remove the element corresponding to the given key.
 int size()
           
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

size

int size()
Returns:
The size of this set.

contains

boolean contains(K key)
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

E get(K key)
Return the stored element which is equal to the given key. This operation is similar to Map.get(Object).

Parameters:
key - The given key.
Returns:
The stored element if it exists. Otherwise, return null.
Throws:
NullPointerException - if key == null.

put

E put(E element)
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 to Map.put(Object, Object) but is different from Set.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

E remove(K key)
Remove the element corresponding to the given key. This operation is similar to Map.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.


Copyright © 2009 The Apache Software Foundation