edu.rit.numeric
Class ListXYSeries

java.lang.Object
  extended by edu.rit.numeric.XYSeries
      extended by edu.rit.numeric.ListXYSeries
All Implemented Interfaces:
Externalizable, Serializable

public class ListXYSeries
extends XYSeries
implements Externalizable

Class ListXYSeries provides a series of (x,y) pairs of real values (type double); the series is variable-length.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.rit.numeric.XYSeries
XYSeries.Regression
 
Constructor Summary
ListXYSeries()
          Construct a new zero-length XY series.
 
Method Summary
 ListXYSeries add(double... data)
          Add the given data to this series.
 ListXYSeries add(double[] x, double[] y)
          Add the given data arrays to this series.
 ListXYSeries add(double[] x, double[] y, int off, int len)
          Add a portion of the given data arrays to this series.
 ListXYSeries add(double x, double y)
          Add the given data to this series.
 ListXYSeries add(Scanner scanner)
          Add data read from the given scanner to this series.
 ListXYSeries add(XYSeries theSeries)
          Add the given XYSeries to this series.
 ListXYSeries add(XYSeries theSeries, int off, int len)
          Add a portion of the given XYSeries to this series.
 ListXYSeries clear()
          Clear this series.
 int length()
          Returns the number of values in this series.
 void readExternal(ObjectInput in)
          Read this series from the given object input stream.
 void writeExternal(ObjectOutput out)
          Write this series to the given object output stream.
 double x(int i)
          Returns the given X value in this series.
 double y(int i)
          Returns the given Y value in this series.
 
Methods inherited from class edu.rit.numeric.XYSeries
isEmpty, linearRegression, maxX, maxY, minX, minY, print, print, print, xSeries, ySeries
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ListXYSeries

public ListXYSeries()
Construct a new zero-length XY series.

Method Detail

length

public int length()
Returns the number of values in this series.

Specified by:
length in class XYSeries
Returns:
Length.

x

public double x(int i)
Returns the given X value in this series.

Specified by:
x in class XYSeries
Parameters:
i - Index.
Returns:
The X value in this series at index i.
Throws:
ArrayIndexOutOfBoundsException - (unchecked exception) Thrown if i is not in the range 0 .. length()-1.

y

public double y(int i)
Returns the given Y value in this series.

Specified by:
y in class XYSeries
Parameters:
i - Index.
Returns:
The Y value in this series at index i.
Throws:
ArrayIndexOutOfBoundsException - (unchecked exception) Thrown if i is not in the range 0 .. length()-1.

clear

public ListXYSeries clear()
Clear this series.

Returns:
This series.

add

public ListXYSeries add(double x,
                        double y)
Add the given data to this series.

Parameters:
x - X value.
y - Y value.
Returns:
This series.

add

public ListXYSeries add(double... data)
Add the given data to this series. The data values are grouped into pairs, where the first data value is the X value and the second data value is the Y value. Each pair of data values is added to this series as though by the add(double,double) method. It is assumed that there are an even number of data values.

Parameters:
data - Data values.
Returns:
This series.

add

public ListXYSeries add(double[] x,
                        double[] y)
Add the given data arrays to this series. Each element of x and y is added to this series as though by the add(double,double) method. It is assumed that x and y are the same length.

Parameters:
x - Array of X values.
y - Array of Y values.
Returns:
This series.
Throws:
NullPointerException - (unchecked exception) Thrown if x or y is null.

add

public ListXYSeries add(double[] x,
                        double[] y,
                        int off,
                        int len)
Add a portion of the given data arrays to this series. Each element of x and y from index off through index off+len-1 inclusive is added to this series as though by the add(double,double) method.

Parameters:
x - Array of X values.
y - Array of Y values.
off - Index of first element to add.
len - Number of elements to add.
Returns:
This series.
Throws:
NullPointerException - (unchecked exception) Thrown if x or y is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if off < 0, len < 0, off+len > x.length, or off+len > y.length.

add

public ListXYSeries add(XYSeries theSeries)
Add the given XYSeries to this series. Each corresponding X and Y value in the given X-Y series is added to this series as though by the add(double,double) method.

Parameters:
theSeries - X-Y series.
Returns:
This series.
Throws:
NullPointerException - (unchecked exception) Thrown if theSeries is null.

add

public ListXYSeries add(XYSeries theSeries,
                        int off,
                        int len)
Add a portion of the given XYSeries to this series. Each corresponding X and Y value in the given X-Y series from index off through index off+len-1 inclusive is added to this series as though by the add(double,double) method.

Parameters:
theSeries - X-Y series.
off - Index of first element to add.
len - Number of elements to add.
Returns:
This series.
Throws:
NullPointerException - (unchecked exception) Thrown if theSeries is null.
IndexOutOfBoundsException - (unchecked exception) Thrown if off < 0, len < 0, or off+len > theSeries.length().

add

public ListXYSeries add(Scanner scanner)
Add data read from the given scanner to this series. Double values are read from the scanner until there are no more. Each pair of consecutive double values is added to this series as though by the add(double,double) method. Any leftover double value is discarded. The add() method does not close the scanner when finished.

To read data from a file, pass a scanner constructed on top of the file; to read data from an input stream, pass a scanner constructed on top of the input stream; and so on.

Parameters:
scanner - Scanner.
Returns:
This series.
Throws:
NullPointerException - (unchecked exception) Thrown if scanner is null.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Write this series to the given object output stream.

Specified by:
writeExternal in interface Externalizable
Parameters:
out - Object output stream.
Throws:
IOException - Thrown if an I/O error occurred.

readExternal

public void readExternal(ObjectInput in)
                  throws IOException
Read this series from the given object input stream.

Specified by:
readExternal in interface Externalizable
Parameters:
in - Object input stream.
Throws:
IOException - Thrown if an I/O error occurred.


Copyright © 2005-2012 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.