org.apache.hadoop.hdfs.util
Class GSetByHashMap<K,E extends K>

java.lang.Object
  extended by org.apache.hadoop.hdfs.util.GSetByHashMap<K,E>
All Implemented Interfaces:
Iterable<E>, GSet<K,E>

@InterfaceAudience.Private
public class GSetByHashMap<K,E extends K>
extends Object
implements GSet<K,E>

A GSet implementation by HashMap.


Constructor Summary
GSetByHashMap(int initialCapacity, float loadFactor)
           
 
Method Summary
 boolean contains(K k)
          Does this set contain an element corresponding to the given key?
 E get(K k)
          Return the stored element which is equal to the given key.
 Iterator<E> iterator()
           
 E put(E element)
          Add/replace an element.
 E remove(K k)
          Remove the element corresponding to the given key.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GSetByHashMap

public GSetByHashMap(int initialCapacity,
                     float loadFactor)
Method Detail

size

public int size()
Specified by:
size in interface GSet<K,E extends K>
Returns:
The size of this set.

contains

public boolean contains(K k)
Description copied from interface: GSet
Does this set contain an element corresponding to the given key?

Specified by:
contains in interface GSet<K,E extends K>
Parameters:
k - The given key.
Returns:
true if the given key equals to a stored element. Otherwise, return false.

get

public E get(K k)
Description copied from interface: GSet
Return the stored element which is equal to the given key. This operation is similar to Map.get(Object).

Specified by:
get in interface GSet<K,E extends K>
Parameters:
k - The given key.
Returns:
The stored element if it exists. Otherwise, return null.

put

public E put(E element)
Description copied from interface: GSet
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.

Specified by:
put in interface GSet<K,E extends K>
Parameters:
element - The element being put.
Returns:
the previous stored element if there is any. Otherwise, return null.

remove

public E remove(K k)
Description copied from interface: GSet
Remove the element corresponding to the given key. This operation is similar to Map.remove(Object).

Specified by:
remove in interface GSet<K,E extends K>
Parameters:
k - The key of the element being removed.
Returns:
If such element exists, return it. Otherwise, return null.

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E extends K>


Copyright © 2009 The Apache Software Foundation