Package coconad

Class Train

java.lang.Object
coconad.Train
All Implemented Interfaces:
Serializable

public class Train extends Object implements Serializable
Class for trains.
Since:
2013.11.28
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
    the current number of times
    protected util.IdMap
    the underlying item base
    protected int
    the associated item identifier
    static final int
    read/write mode: train with preceding item
    protected double
    the maximal time
    protected double
    the minimal time
    protected int
    the associated numeric identifier (item name is numeric)
    static final int
    read/write mode: pure train, that is, no item
    protected double[]
    the times of the train
  • Constructor Summary

    Constructors
    Constructor
    Description
    Train(String item)
    Create an empty (spike/event) train.
    Train(util.IdMap ibase, String item)
    Create an empty (spike/event) train.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    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
    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
    Get the length/size of the (spike/event) train.
    double
    getTime(int i)
    Get a (spike/event) time of the train.
    void
    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(util.IdMap ibase, Reader reader, int mode)
    Parse a (spike/event) train.
    static Train
    parse(util.IdMap ibase, String desc, int mode)
    Parse a (spike/event) train.
    static Train
    parse(util.IdMap ibase, util.TableReader reader, int mode)
    Parse a (spike/event) train.
    void
    Sort a (spike/event) train (that is, the times in it).
    Create a string description of a (spike/event) train.
    void
    write(util.TableWriter writer, int mode)
    Write a (spike/event) train.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ITEM_TRAIN

      public static final int ITEM_TRAIN
      read/write mode: train with preceding item
      See Also:
    • PURE_TRAIN

      public static final int PURE_TRAIN
      read/write mode: pure train, that is, no item
      See Also:
    • ibase

      protected util.IdMap ibase
      the underlying item base
    • nid

      protected int nid
      the associated numeric identifier (item name is numeric)
    • item

      protected int item
      the associated item identifier
    • times

      protected double[] times
      the times of the train
    • cnt

      protected int cnt
      the current number of times
    • min

      protected double min
      the minimal time
    • max

      protected double max
      the maximal time
  • Constructor Details

    • Train

      public Train(String item)
      Create an empty (spike/event) train.
      Parameters:
      item - the item for which to create the train
      Since:
      2013.11.28 (Christian Borgelt)
    • Train

      public Train(util.IdMap ibase, String item)
      Create an empty (spike/event) train.
      Parameters:
      ibase - the underlying item base
      item - 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

      public String 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 interval
      end - 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

      public void write(util.TableWriter writer, int mode) throws IOException
      Write a (spike/event) train.
      Parameters:
      writer - the table writer to write to
      mode - the write mode (ITEM_TRAIN or PURE_TRAIN)
      Throws:
      IOException - if a write error occurs
      Since:
      2013.11.28 (Christian Borgelt)
    • parse

      public static Train parse(util.IdMap ibase, util.TableReader reader, int mode) throws IOException
      Parse a (spike/event) train.
      Parameters:
      ibase - the underlying item base
      reader - the reader to read from
      mode - the record format mode
      Returns:
      the parsed (spike/event) train
      Throws:
      IOException - if a read error occurs
      Since:
      2013.11.28 (Christian Borgelt)
    • parse

      public static Train parse(util.IdMap ibase, Reader reader, int mode) throws IOException
      Parse a (spike/event) train.
      Parameters:
      ibase - the underlying item base
      reader - the reader to read from
      mode - the record format mode
      Returns:
      the parsed (spike/event) train
      Throws:
      IOException - if a read error occurs
      Since:
      2013.11.28 (Christian Borgelt)
    • parse

      public static Train parse(util.IdMap ibase, String desc, int mode) throws IOException
      Parse a (spike/event) train.
      Parameters:
      ibase - the underlying item base
      desc - the string description to parse
      mode - the record format mode
      Returns:
      the parsed (spike/event) train
      Throws:
      IOException - if a read error occurs
      Since:
      2013.11.28 (Christian Borgelt)
    • parse

      public static Train parse(util.IdMap ibase, InputStream inp, int mode) throws IOException
      Parse a (spike/event) train.
      Parameters:
      ibase - the underlying item base
      inp - the input stream to read from
      mode - the record format mode
      Returns:
      the parsed (spike/event) train
      Throws:
      IOException - if a read error occurs
      Since:
      2013.11.28 (Christian Borgelt)
    • toString

      public String toString()
      Create a string description of a (spike/event) train.
      Overrides:
      toString in class Object
      Returns:
      the created string description
      Since:
      2013.11.28 (Christian Borgelt)