Package coconad
Class TrainSet
java.lang.Object
coconad.TrainSet
- All Implemented Interfaces:
Serializable
Class for a set of trains.
- Since:
- 2013.11.27
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
the current number of trainsprotected util.IdMap
the underlying item basestatic final int
read/write mode: pair of item and timestatic final int
read/write mode: train with preceding itemprotected double
the maximum event/spike timeprotected int
the maximal length of a trainprotected double
the minimum event/spike timestatic final int
read/write mode: pure train, that is, no itemstatic final int
read/write mode: pair of time and itemprotected Train[]
the set of trains -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Add a train.void
filter
(double start, double end) Filter a train set.double[][]
Get all trains as arrays of floating point values.int
getItem
(int i) Get the item identifier of a (spike/event) train.util.IdMap
Get the underlying item base.int
getItemId
(int i) Get the item identifier of a (spike/event) train.getItemName
(int i) Get the item name of a (spike/event) train.int
Get the maximal length of a train.double
Get the maximum time.double
Get the minimum time.int
getSize()
Get the number of (spike/event) trains.getTrain
(int i) Get a train.static void
Main function for testing some basic functionality.void
pack()
Pack the trains of a set, i.e., optimize memory usage.static TrainSet
parse
(util.IdMap ibase, InputStream inp, int mode) Parse a set of (spike/event) trains.static TrainSet
Parse a set of (spike/event) trains.static TrainSet
Parse a set of (spike/event) trains.static TrainSet
parse
(util.IdMap ibase, util.TableReader reader, int mode) Parse a set of (spike/event) trains.void
sort()
Sort trains by their item names.void
Sort a train set (that is, sort all contained trains).void
write
(util.TableWriter writer, int mode) Write a set of trains.
-
Field Details
-
ITEM_TRAIN
public static final int ITEM_TRAINread/write mode: train with preceding item- See Also:
-
PURE_TRAIN
public static final int PURE_TRAINread/write mode: pure train, that is, no item- See Also:
-
ITEM_TIME
public static final int ITEM_TIMEread/write mode: pair of item and time- See Also:
-
TIME_ITEM
public static final int TIME_ITEMread/write mode: pair of time and item- See Also:
-
ibase
protected util.IdMap ibasethe underlying item base -
trains
the set of trains -
cnt
protected int cntthe current number of trains -
maxlen
protected int maxlenthe maximal length of a train -
min
protected double minthe minimum event/spike time -
max
protected double maxthe maximum event/spike time
-
-
Constructor Details
-
TrainSet
public TrainSet()Create an empty set of trains.- Since:
- 2013.11.27 (Christian Borgelt)
-
TrainSet
public TrainSet(util.IdMap ibase) Create an empty set of trains.- Parameters:
ibase
- the underlying item base- Since:
- 2013.11.27 (Christian Borgelt)
-
-
Method Details
-
getItemBase
public util.IdMap getItemBase()Get the underlying item base.- Returns:
- the underlying item base
- Since:
- 2013.11.27 (Christian Borgelt)
-
getItem
public int getItem(int i) Get the item identifier of a (spike/event) train.- Parameters:
i
- the index of the train of which to get the item- Returns:
- the item of the train with index
i
- Since:
- 2016.08.26 (Christian Borgelt)
-
getItemId
public int getItemId(int i) Get the item identifier of a (spike/event) train.- Parameters:
i
- the index of the train of which to get the item- Returns:
- the item of the train with index
i
- Since:
- 2016.08.26 (Christian Borgelt)
-
getItemName
Get the item name of a (spike/event) train.- Parameters:
i
- the index of the train of which to get the item name- Returns:
- the item name of the train with index
i
- Since:
- 2013.11.28 (Christian Borgelt)
-
getSize
public int getSize()Get the number of (spike/event) trains.- Returns:
- the number of trains
- Since:
- 2013.11.28 (Christian Borgelt)
-
getTrain
Get a train.- Parameters:
i
- the index of the train- Returns:
- the train with index
i
- Since:
- 2013.11.28 (Christian Borgelt)
-
getAllTrains
public double[][] getAllTrains()Get all trains as arrays of floating point values.- Returns:
- all trains as arrays of floating point values
- Since:
- 2013.11.28 (Christian Borgelt)
-
addTrain
Add a train.- Parameters:
train
- the train to add- Returns:
- the index of the train in the set
- Since:
- 2013.11.28 (Christian Borgelt)
-
getMaxLength
public int getMaxLength()Get the maximal length of a train.- Returns:
- the maximal size of a train
- Since:
- 2013.11.28 (Christian Borgelt)
-
sort
public void sort()Sort trains by their item names.- Since:
- 2013.11.28 (Christian Borgelt)
-
sortTimes
public void sortTimes()Sort a train set (that is, sort all contained trains).- Since:
- 2013.12.03 (Christian Borgelt)
-
filter
public void filter(double start, double end) Filter a train set.- Parameters:
start
- the start of the filter intervalend
- the end of the filter interval- Since:
- 2013.11.28 (Christian Borgelt)
-
pack
public void pack()Pack the trains of a set, i.e., optimize memory usage.- Since:
- 2013.11.29 (Christian Borgelt)
-
getMinTime
public double getMinTime()Get the minimum time.- Returns:
- the minimum time
- Since:
- 2013.11.29 (Christian Borgelt)
-
getMaxTime
public double getMaxTime()Get the maximum time.- Returns:
- the maximum time
- Since:
- 2013.11.29 (Christian Borgelt)
-
write
Write a set of trains.- Parameters:
writer
- the table writer to write tomode
- the read mode of the writer- Throws:
IOException
- if a write error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
parse
public static TrainSet parse(util.IdMap ibase, util.TableReader reader, int mode) throws IOException Parse a set of (spike/event) trains.- Parameters:
ibase
- the underlying item basereader
- the table reader to read frommode
- the read mode of the writer- Returns:
- the parsed set of (spike/event) trains
- Throws:
IOException
- if a read error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
parse
Parse a set of (spike/event) trains.- Parameters:
ibase
- the underlying item basereader
- the reader to read frommode
- the read mode of the writer- Returns:
- the parsed set of (spike/event) trains
- Throws:
IOException
- if a read error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
parse
Parse a set of (spike/event) trains.- Parameters:
ibase
- the underlying item basedesc
- the string description to parsemode
- the read mode of the writer- Returns:
- the parsed set of (spike/event) trains
- Throws:
IOException
- if a read error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
parse
Parse a set of (spike/event) trains.- Parameters:
ibase
- the underlying item baseinp
- the input stream to read frommode
- the read mode of the writer- Returns:
- the parsed set of (spike/event) trains
- Throws:
IOException
- if a read error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
main
Main function for testing some basic functionality.It is tried to parse the file that is given as the first command line argument as a set of trains.
- Parameters:
args
- the command line arguments- Since:
- 2013.11.28 (Christian Borgelt)
-