Package adams.data.binning
Class Bin<T>
- java.lang.Object
-
- adams.data.binning.Bin<T>
-
- Type Parameters:
T- the type of payload
- All Implemented Interfaces:
CloneHandler<Bin<T>>,Mergeable<Bin<T>>,Serializable,Comparable<Bin<T>>
public class Bin<T> extends Object implements Serializable, Comparable<Bin<T>>, CloneHandler<Bin<T>>, Mergeable<Bin<T>>
Represents a single bin.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected doublem_Endthe end of the bin.protected intm_Indexthe bin index.protected BaseIntervalm_Intervalthe range.protected List<Binnable<T>>m_Objectsthe binnable objects that belong to this bin.protected doublem_Startthe start of the bin.
-
Constructor Summary
Constructors Constructor Description Bin(int index, double start, double end, BaseInterval interval)Initializes the bin.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Binnable<T> object)Adds the object to the list of objects belong to this bin.voidaddAll(Collection<Binnable<T>> objects)Adds the objects to the list of objects belong to this bin.intcompareTo(Bin<T> o)Uses the index of the bin for comparison.booleanequals(Object obj)Returns true if the other object is a bin with the same index.booleanfits(Binnable<T> object)Checks whether the object belongs to this bin.List<Binnable<T>>get()Returns the list of objects in the bin.Bin<T>getClone()Returns a clone of the object.doublegetEnd()Returns the end of the bin.intgetIndex()Returns the index of the bin.BaseIntervalgetInterval()Returns the complete interval of the bin.doublegetStart()Returns the start of the bin.voidmergeWith(Bin<T> other)Merges its own data with the one provided by the specified object.intsize()Returns the number of stored objects.StringtoString()Returns a short description of the bin.StringtoString(int decimals)Returns a short description of the bin.
-
-
-
Field Detail
-
m_Index
protected int m_Index
the bin index.
-
m_Start
protected double m_Start
the start of the bin.
-
m_End
protected double m_End
the end of the bin.
-
m_Interval
protected BaseInterval m_Interval
the range.
-
-
Constructor Detail
-
Bin
public Bin(int index, double start, double end, BaseInterval interval)Initializes the bin.- Parameters:
index- the index of the binstart- the starting pointinterval- the complete range
-
-
Method Detail
-
getIndex
public int getIndex()
Returns the index of the bin.- Returns:
- the index
-
getStart
public double getStart()
Returns the start of the bin.- Returns:
- the start
-
getEnd
public double getEnd()
Returns the end of the bin.- Returns:
- the end
-
getInterval
public BaseInterval getInterval()
Returns the complete interval of the bin.- Returns:
- the interval
-
fits
public boolean fits(Binnable<T> object)
Checks whether the object belongs to this bin.- Parameters:
object- the object to check- Returns:
- true if it fits
-
add
public void add(Binnable<T> object)
Adds the object to the list of objects belong to this bin.- Parameters:
object- the object to add
-
addAll
public void addAll(Collection<Binnable<T>> objects)
Adds the objects to the list of objects belong to this bin.- Parameters:
objects- the objects to add
-
size
public int size()
Returns the number of stored objects.- Returns:
- the number of objects
- See Also:
get()
-
compareTo
public int compareTo(Bin<T> o)
Uses the index of the bin for comparison.- Specified by:
compareToin interfaceComparable<T>- Parameters:
o- the other bin- Returns:
- less than, equal to, or larger based on the index comparison
-
equals
public boolean equals(Object obj)
Returns true if the other object is a bin with the same index.
-
getClone
public Bin<T> getClone()
Returns a clone of the object.- Specified by:
getClonein interfaceCloneHandler<T>- Returns:
- the clone
-
mergeWith
public void mergeWith(Bin<T> other)
Merges its own data with the one provided by the specified object.
-
toString
public String toString()
Returns a short description of the bin.
-
toString
public String toString(int decimals)
Returns a short description of the bin.- Parameters:
decimals- the number of decimals to use in the output, -1 for no limit- Returns:
- the description
-
-