javanpst.data.structures.sequence
Class NumericSequence
- java.lang.Object
-
- javanpst.data.structures.sequence.Sequence
-
- javanpst.data.structures.sequence.NumericSequence
-
public class NumericSequence extends Sequence
A class representing numerical sequences
-
-
Constructor Summary
Constructors Constructor and Description NumericSequence()Default builderNumericSequence(java.util.ArrayList<java.lang.Double> contents)Builder.NumericSequence(double[] contents)Builder.NumericSequence(NumericSequence copy)Copy constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidappend(java.lang.Object value)Adds an element to the end of the sequencevoidclear()Clear the sequencedoubleget(int index)Get an element of the sequencejava.util.ArrayList<java.lang.Double>getSequence()Returns the contents of the sequence as an arrayvoidprepend(java.lang.Object value)Adds an element to the start of the sequencevoidreadCSV(java.lang.String file)Loads a string sequence from a CSV filevoidreadTXT(java.lang.String file)Loads a string sequence from a TXT filevoidreadXML(java.lang.String file)Loads a string sequence from a XML fileintsize()Get the size of the sequencevoidsort()Sorts the sequencejava.lang.StringtoString()To String methodvoidwriteCSV(java.lang.String file, boolean useComma)Writes a string sequence to a CSV filevoidwriteTXT(java.lang.String file)Writes a string sequence to a TXT filevoidwriteXML(java.lang.String file)Writes a string sequence to a XML file
-
-
-
Constructor Detail
-
NumericSequence
public NumericSequence()
Default builder
-
NumericSequence
public NumericSequence(java.util.ArrayList<java.lang.Double> contents)
Builder. Creates a new numeric sequence from an ArrayList of elements.- Parameters:
contents- array of elements
-
NumericSequence
public NumericSequence(double[] contents)
Builder. Creates a new numeric sequence from an array of elements.- Parameters:
contents- array of elements
-
NumericSequence
public NumericSequence(NumericSequence copy)
Copy constructor- Parameters:
copy- sequence to copy
-
-
Method Detail
-
getSequence
public java.util.ArrayList<java.lang.Double> getSequence()
Returns the contents of the sequence as an array- Returns:
- contents of the sequence
-
append
public void append(java.lang.Object value)
Adds an element to the end of the sequence
-
prepend
public void prepend(java.lang.Object value)
Adds an element to the start of the sequence
-
size
public int size()
Get the size of the sequence
-
get
public double get(int index)
Get an element of the sequence- Parameters:
index- index of the element- Returns:
- the element. Double.NaN if index out of range
-
sort
public void sort()
Sorts the sequence
-
toString
public java.lang.String toString()
To String method
-
readXML
public void readXML(java.lang.String file)
Loads a string sequence from a XML file
-
writeXML
public void writeXML(java.lang.String file)
Writes a string sequence to a XML file
-
readCSV
public void readCSV(java.lang.String file)
Loads a string sequence from a CSV file
-
writeCSV
public void writeCSV(java.lang.String file, boolean useComma)Writes a string sequence to a CSV file
-
readTXT
public void readTXT(java.lang.String file)
Loads a string sequence from a TXT file
-
-
DMelt 3.0 © DataMelt by jWork.ORG