Package org.gephi.graph.api.types
Class IntervalMap<T>
- java.lang.Object
-
- org.gephi.graph.api.types.IntervalMap<T>
-
- Type Parameters:
T- Value type
- Direct Known Subclasses:
IntervalBooleanMap,IntervalByteMap,IntervalCharMap,IntervalDoubleMap,IntervalFloatMap,IntervalIntegerMap,IntervalLongMap,IntervalShortMap,IntervalStringMap
public abstract class IntervalMap<T> extends Object implements TimeMap<Interval,T>
Abstract class that implement a sorted map between intervals and attribute values.Implementations which extend this class customize the map for a unique type, which is represented by the
Tparameter.
-
-
Constructor Summary
Constructors Constructor Description IntervalMap()Default constructor.IntervalMap(int capacity)Constructor with capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Empties this map.booleancontains(double timestamp)Returns true if this map contains an interval that starts or ends attimestamp.booleancontains(Interval interval)Returns true if this map contains the given key.booleanequals(Object obj)Objectget(Interval interval, Estimator estimator)Get the estimated value for the given interval.Tget(Interval interval, T defaultValue)Get the value for the given key.double[]getIntervals()Returns an array of all intervals in this set.inthashCode()booleanisEmpty()Returns true if this map is empty.booleanput(Interval interval, T value)Put the value at the given key.booleanremove(Interval interval)Remove the value at the given key.intsize()Returns the size.Interval[]toKeysArray()Returns all the keys as an array.StringtoString()StringtoString(TimeFormat timeFormat)Returns this map as a string.StringtoString(TimeFormat timeFormat, org.joda.time.DateTimeZone timeZone)Returns this map as a string.T[]toValuesArray()Returns all the values as an array.-
Methods inherited from interface org.gephi.graph.api.types.TimeMap
getTypeClass, isSupported
-
-
-
-
Constructor Detail
-
IntervalMap
public IntervalMap()
Default constructor.The map is empty with zero capacity.
-
IntervalMap
public IntervalMap(int capacity)
Constructor with capacity.Using this constructor can improve performances if the number of timestamps is known in advance as it minimizes array resizes.
- Parameters:
capacity- timestamp capacity
-
-
Method Detail
-
put
public boolean put(Interval interval, T value)
Description copied from interface:TimeMapPut the value at the given key.
-
remove
public boolean remove(Interval interval)
Description copied from interface:TimeMapRemove the value at the given key.
-
get
public Object get(Interval interval, Estimator estimator)
Description copied from interface:TimeMapGet the estimated value for the given interval.The estimator is used to determine the way multiple interval values are merged together (e.g average, first, median).
-
get
public T get(Interval interval, T defaultValue)
Description copied from interface:TimeMapGet the value for the given key.Return
defaultValueif the value is not found.
-
toValuesArray
public T[] toValuesArray()
Description copied from interface:TimeMapReturns all the values as an array.- Specified by:
toValuesArrayin interfaceTimeMap<Interval,T>- Returns:
- values array
-
size
public int size()
Description copied from interface:TimeMapReturns the size.
-
isEmpty
public boolean isEmpty()
Description copied from interface:TimeMapReturns true if this map is empty.
-
contains
public boolean contains(double timestamp)
Returns true if this map contains an interval that starts or ends attimestamp.- Parameters:
timestamp- timestamp- Returns:
- true if contains, false otherwise
-
contains
public boolean contains(Interval interval)
Description copied from interface:TimeMapReturns true if this map contains the given key.
-
toKeysArray
public Interval[] toKeysArray()
Description copied from interface:TimeMapReturns all the keys as an array.- Specified by:
toKeysArrayin interfaceTimeMap<Interval,T>- Returns:
- keys array
-
getIntervals
public double[] getIntervals()
Returns an array of all intervals in this set.The intervals are represented in a flat and sorted array (e.g. {[1.0,2.0], [5.0,6.0]}) returns [1.0,2.0,5.0,6.0]).
This method may return a reference to the underlying array so clients should make a copy if the array is written to.
- Returns:
- array of all intervals
-
clear
public void clear()
Description copied from interface:TimeMapEmpties this map.
-
toString
public String toString(TimeFormat timeFormat, org.joda.time.DateTimeZone timeZone)
Description copied from interface:TimeMapReturns this map as a string.
-
toString
public String toString(TimeFormat timeFormat)
Description copied from interface:TimeMapReturns this map as a string.
-
-