chord.util
Class SetUtils

java.lang.Object
  extended by chord.util.SetUtils

public class SetUtils
extends java.lang.Object

Set related utilities.

Author:
Mayur Naik (mhn@cs.stanford.edu)

Field Summary
static int DEFAULT_ESTIMATED_SIZE
          Default estimated size of a set.
static int THRESHOLD
          Threshold that, given the estimated size of a set to be created, is used to decide whether to use a lightweight (e.g.
 
Constructor Summary
SetUtils()
           
 
Method Summary
static
<T> java.util.Set<T>
iterableToSet(java.lang.Iterable<T> c, int size)
          Create a set from the given iterable of the given estimated size.
static
<T> java.util.Set<T>
newSet()
          Create a new set of the default estimated size.
static
<T> java.util.Set<T>
newSet(int size)
          Create a new set of the given estimated size.
static
<T> java.util.Set<T>
newSet(java.util.Set<T> c)
          Create a copy of the given set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ESTIMATED_SIZE

public static final int DEFAULT_ESTIMATED_SIZE
Default estimated size of a set.

See Also:
Constant Field Values

THRESHOLD

public static final int THRESHOLD
Threshold that, given the estimated size of a set to be created, is used to decide whether to use a lightweight (e.g. ArraySet) or heavyweight (e.g. HashSet) implementation.

See Also:
Constant Field Values
Constructor Detail

SetUtils

public SetUtils()
Method Detail

newSet

public static <T> java.util.Set<T> newSet()
Create a new set of the default estimated size. THRESHOLD is used to choose the implementation of the created set based on the default estimated size.

Type Parameters:
T - The type of elements in the set.
Returns:
The created set.

newSet

public static <T> java.util.Set<T> newSet(int size)
Create a new set of the given estimated size. THRESHOLD is used to choose the implementation of the create set based on the given estimated size.

Type Parameters:
T - The type of elements in the set.
Parameters:
size - The estimated size of the set.
Returns:
The created set.

newSet

public static <T> java.util.Set<T> newSet(java.util.Set<T> c)
Create a copy of the given set. THRESHOLD is used to choose the implementation of the created set based on the size of the given set.

Type Parameters:
T - The type of elements in the given set.
Parameters:
c - The given set to be copied.
Returns:
The created set containing the elements in the given set.

iterableToSet

public static <T> java.util.Set<T> iterableToSet(java.lang.Iterable<T> c,
                                                 int size)
Create a set from the given iterable of the given estimated size. THRESHOLD is used to choose the implementation of the created set based on the given estimated size.

Type Parameters:
T - The type of elements in the iterable.
Parameters:
c - The iterable.
size - The estimated size of the iterable.
Returns:
The created set containing the elements in the iterable.