Package coconad
Class Train
java.lang.Object
coconad.Train
- All Implemented Interfaces:
Serializable
Class for trains.
- Since:
- 2013.11.28
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected int
the current number of timesprotected util.IdMap
the underlying item baseprotected int
the associated item identifierstatic final int
read/write mode: train with preceding itemprotected double
the maximal timeprotected double
the minimal timeprotected int
the associated numeric identifier (item name is numeric)static final int
read/write mode: pure train, that is, no itemprotected double[]
the times of the train -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
addTime
(double time) Add a (spike/event) time to the train.void
filter
(double start, double end) Filter a (spike/event) train.double[]
Get all (spike/event) times of the train (array length/size fits only after packing).int
getItem()
Get the associated item (i.e., its identifier).int
Get the associated item (i.e., its identifier).Get the name of the associated item.int
Get the length/size of the (spike/event) train.double
Get the maximum (spike/event) time.double
Get the minimum (spike/event) time.int
getSize()
Get the length/size of the (spike/event) train.double
getTime
(int i) Get a (spike/event) time of the train.void
pack()
Pack a (spike/event) train, i.e., optimize memory usage.static Train
parse
(util.IdMap ibase, InputStream inp, int mode) Parse a (spike/event) train.static Train
Parse a (spike/event) train.static Train
Parse a (spike/event) train.static Train
parse
(util.IdMap ibase, util.TableReader reader, int mode) Parse a (spike/event) train.void
sort()
Sort a (spike/event) train (that is, the times in it).toString()
Create a string description of a (spike/event) train.void
write
(util.TableWriter writer, int mode) Write a (spike/event) train.
-
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:
-
ibase
protected util.IdMap ibasethe underlying item base -
nid
protected int nidthe associated numeric identifier (item name is numeric) -
item
protected int itemthe associated item identifier -
times
protected double[] timesthe times of the train -
cnt
protected int cntthe current number of times -
min
protected double minthe minimal time -
max
protected double maxthe maximal time
-
-
Constructor Details
-
Train
Create an empty (spike/event) train.- Parameters:
item
- the item for which to create the train- Since:
- 2013.11.28 (Christian Borgelt)
-
Train
Create an empty (spike/event) train.- Parameters:
ibase
- the underlying item baseitem
- the item for which to create the train- Since:
- 2013.11.28 (Christian Borgelt)
-
-
Method Details
-
getItem
public int getItem()Get the associated item (i.e., its identifier).- Returns:
- the identifier of the associated item
- Since:
- 2013.11.28 (Christian Borgelt)
-
getItemId
public int getItemId()Get the associated item (i.e., its identifier).- Returns:
- the identifier of the associated item
- Since:
- 2016.08.25 (Christian Borgelt)
-
getItemName
Get the name of the associated item.- Returns:
- the name of the associated item
- Since:
- 2013.11.28 (Christian Borgelt)
-
getLength
public int getLength()Get the length/size of the (spike/event) train.- Returns:
- the length/size of the (spike/event) train
- Since:
- 2013.11.28 (Christian Borgelt)
-
getSize
public int getSize()Get the length/size of the (spike/event) train.- Returns:
- the length/size of the (spike/event) train
- Since:
- 2016.08.25 (Christian Borgelt)
-
getMinTime
public double getMinTime()Get the minimum (spike/event) time.- Returns:
- the minimum time
- Since:
- 2013.11.29 (Christian Borgelt)
-
getMaxTime
public double getMaxTime()Get the maximum (spike/event) time.- Returns:
- the maximum time
- Since:
- 2013.11.29 (Christian Borgelt)
-
getTime
public double getTime(int i) Get a (spike/event) time of the train.- Parameters:
i
- the index of the time- Returns:
- the value of the ith time
- Since:
- 2013.11.28 (Christian Borgelt)
-
getAllTimes
public double[] getAllTimes()Get all (spike/event) times of the train (array length/size fits only after packing).- Returns:
- the array of times of the (spike/event) train
- Since:
- 2013.11.29 (Christian Borgelt)
-
addTime
public int addTime(double time) Add a (spike/event) time to the train.- Parameters:
time
- the (spike/event) time to add- Returns:
- the index of the new time
- Since:
- 2013.11.28 (Christian Borgelt)
-
sort
public void sort()Sort a (spike/event) train (that is, the times in it).- Since:
- 2013.12.03 (Christian Borgelt)
-
filter
public void filter(double start, double end) Filter a (spike/event) train.- 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 a (spike/event) train, i.e., optimize memory usage.- Since:
- 2013.11.28 (Christian Borgelt)
-
write
Write a (spike/event) train.- Parameters:
writer
- the table writer to write tomode
- the write mode (ITEM_TRAIN
orPURE_TRAIN
)- Throws:
IOException
- if a write error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
parse
Parse a (spike/event) train.- Parameters:
ibase
- the underlying item basereader
- the reader to read frommode
- the record format mode- Returns:
- the parsed (spike/event) train
- Throws:
IOException
- if a read error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
parse
Parse a (spike/event) train.- Parameters:
ibase
- the underlying item basereader
- the reader to read frommode
- the record format mode- Returns:
- the parsed (spike/event) train
- Throws:
IOException
- if a read error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
parse
Parse a (spike/event) train.- Parameters:
ibase
- the underlying item basedesc
- the string description to parsemode
- the record format mode- Returns:
- the parsed (spike/event) train
- Throws:
IOException
- if a read error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
parse
Parse a (spike/event) train.- Parameters:
ibase
- the underlying item baseinp
- the input stream to read frommode
- the record format mode- Returns:
- the parsed (spike/event) train
- Throws:
IOException
- if a read error occurs- Since:
- 2013.11.28 (Christian Borgelt)
-
toString
Create a string description of a (spike/event) train.
-