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
T
parameter.
-
-
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 void
clear()
Empties this map.boolean
contains(double timestamp)
Returns true if this map contains an interval that starts or ends attimestamp
.boolean
contains(Interval interval)
Returns true if this map contains the given key.boolean
equals(Object obj)
Object
get(Interval interval, Estimator estimator)
Get the estimated value for the given interval.T
get(Interval interval, T defaultValue)
Get the value for the given key.double[]
getIntervals()
Returns an array of all intervals in this set.int
hashCode()
boolean
isEmpty()
Returns true if this map is empty.boolean
put(Interval interval, T value)
Put the value at the given key.boolean
remove(Interval interval)
Remove the value at the given key.int
size()
Returns the size.Interval[]
toKeysArray()
Returns all the keys as an array.String
toString()
String
toString(TimeFormat timeFormat)
Returns this map as a string.String
toString(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:TimeMap
Put the value at the given key.
-
remove
public boolean remove(Interval interval)
Description copied from interface:TimeMap
Remove the value at the given key.
-
get
public Object get(Interval interval, Estimator estimator)
Description copied from interface:TimeMap
Get 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:TimeMap
Get the value for the given key.Return
defaultValue
if the value is not found.
-
toValuesArray
public T[] toValuesArray()
Description copied from interface:TimeMap
Returns all the values as an array.- Specified by:
toValuesArray
in interfaceTimeMap<Interval,T>
- Returns:
- values array
-
size
public int size()
Description copied from interface:TimeMap
Returns the size.
-
isEmpty
public boolean isEmpty()
Description copied from interface:TimeMap
Returns 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:TimeMap
Returns true if this map contains the given key.
-
toKeysArray
public Interval[] toKeysArray()
Description copied from interface:TimeMap
Returns all the keys as an array.- Specified by:
toKeysArray
in 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:TimeMap
Empties this map.
-
toString
public String toString(TimeFormat timeFormat, org.joda.time.DateTimeZone timeZone)
Description copied from interface:TimeMap
Returns this map as a string.
-
toString
public String toString(TimeFormat timeFormat)
Description copied from interface:TimeMap
Returns this map as a string.
-
-