org.opensha.sra.riskmaps.func
Class DiscreteSet

java.lang.Object
  extended by org.opensha.sra.riskmaps.func.DiscreteSet
All Implemented Interfaces:
SetAPI

public class DiscreteSet
extends Object
implements SetAPI

This class represents the mathematical idea of a discrete set. A discrete set contains at most a finite number of values.

 -=* CHANGE LOG *=-
 06/19/2008 -- EMM: Original implementation.

Version:
0.0.1
Author:
Eric Martinez

Constructor Summary
DiscreteSet(double[] values)
          Creates a discrete set containing the values in the given values array.
 
Method Summary
 boolean contains(double x)
          Checks if a given value x exists in this set.
 boolean equals(SetAPI set)
          Checks whether the calling SetAPI and the passed set are logically equal.
 SetAPI intersectionOf(SetAPI set)
          Creates and returns a set whose values are a composite single-copy of any value appearing in both of the calling SetAPI and the passed set.
 double lowerBound()
           
 int size()
           
 double[] toArray()
           
 SetAPI unionWith(SetAPI set)
          Creates and returns a set whose values are a composite single-copy of any value appearing in one or both of the calling SetAPI and the passed set.
 double upperBound()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscreteSet

public DiscreteSet(double[] values)
Creates a discrete set containing the values in the given values array.

Parameters:
values - An array of values to place in the discrete set.
Method Detail

contains

public boolean contains(double x)
Description copied from interface: SetAPI
Checks if a given value x exists in this set. Due to double floating point precision errors, all comparisons should take place within a reasonable tolerance for the specific set. This tolerance is left up to the implementation to determine.

Specified by:
contains in interface SetAPI
Parameters:
x - The value to check for.
Returns:
True of the given value x is in the set, false otherwise.

unionWith

public SetAPI unionWith(SetAPI set)
Description copied from interface: SetAPI
Creates and returns a set whose values are a composite single-copy of any value appearing in one or both of the calling SetAPI and the passed set.

Specified by:
unionWith in interface SetAPI
Returns:
A set whose values are the union of the calling DiscreteSet and the passed set.

intersectionOf

public SetAPI intersectionOf(SetAPI set)
Description copied from interface: SetAPI
Creates and returns a set whose values are a composite single-copy of any value appearing in both of the calling SetAPI and the passed set.

Specified by:
intersectionOf in interface SetAPI
Returns:
A set whose values are the intersection of the calling DiscreteSet and the passed set.

equals

public boolean equals(SetAPI set)
Description copied from interface: SetAPI
Checks whether the calling SetAPI and the passed set are logically equal.

Specified by:
equals in interface SetAPI
Returns:
True if the primitive arrays of values are considrered equal, false otherwise.

lowerBound

public double lowerBound()
Specified by:
lowerBound in interface SetAPI
Returns:
The greatest upper bound of this set, or NaN if the set contains no values. Note: A discrete set that contains no values is not considered the same as an empty set.

upperBound

public double upperBound()
Specified by:
upperBound in interface SetAPI
Returns:
The least upper bound of this set, or NaN if the set contains no values. Note: A discrete set that contains no values is not considered the same as an empty set.

size

public int size()
Returns:
The number of values in this set.

toArray

public double[] toArray()
Returns:
A primitive double array of the values in this set.