Package org.gephi.graph.api.types
Class IntervalSet
- java.lang.Object
-
- org.gephi.graph.api.types.IntervalSet
-
-
Constructor Summary
Constructors Constructor Description IntervalSet()Default constructor.IntervalSet(double[] arr)Constructor with an initial interval set.IntervalSet(int capacity)Constructor with capacity.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(Interval interval)Adds key to this set.voidclear()Empties this set.booleancontains(double timestamp)Returns true if this set contains an interval that starts or ends attimestamp.booleancontains(Interval interval)Returns true if this set containskey.booleanequals(Object obj)double[]getIntervals()Returns an array of all intervals in this set in a flat format.IntervalgetMax()Returns the maximum key in the setDoublegetMaxDouble()Returns the maximum timestamp in the setIntervalgetMin()Returns the minimum key in the setDoublegetMinDouble()Returns the minimum timestamp in the setinthashCode()booleanisEmpty()Returns true if this set is empty.booleanremove(Interval interval)Removes key from this set.intsize()Returns the size of this set.Interval[]toArray()Returns an array of all keys in this set.ObjecttoPrimitiveArray()Returns the same result asTimeSet.toArray()but in a primitive array if the underlying storage is in a primitive form.StringtoString()StringtoString(TimeFormat timeFormat)Returns this set as a string.StringtoString(TimeFormat timeFormat, org.joda.time.DateTimeZone timeZone)Returns this set as a string.
-
-
-
Constructor Detail
-
IntervalSet
public IntervalSet()
Default constructor.The set is empty with zero capacity.
-
IntervalSet
public IntervalSet(int capacity)
Constructor with capacity.Using this constructor can improve performances if the number of intervals is known in advance as it minimizes array resizes.
- Parameters:
capacity- interval capacity
-
IntervalSet
public IntervalSet(double[] arr)
Constructor with an initial interval set.The given array must be sorted and containing an even number of elements.
- Parameters:
arr- initial set content
-
-
Method Detail
-
add
public boolean add(Interval interval)
Description copied from interface:TimeSetAdds key to this set.
-
remove
public boolean remove(Interval interval)
Description copied from interface:TimeSetRemoves key from this set.
-
size
public int size()
Description copied from interface:TimeSetReturns the size of this set.
-
isEmpty
public boolean isEmpty()
Description copied from interface:TimeSetReturns true if this set is empty.
-
getMax
public Interval getMax()
Description copied from interface:TimeSetReturns the maximum key in the set
-
getMin
public Interval getMin()
Description copied from interface:TimeSetReturns the minimum key in the set
-
getMaxDouble
public Double getMaxDouble()
Description copied from interface:TimeSetReturns the maximum timestamp in the set- Specified by:
getMaxDoublein interfaceTimeSet<Interval>- Returns:
- maximum timestamp, or null if the set is empty.
-
getMinDouble
public Double getMinDouble()
Description copied from interface:TimeSetReturns the minimum timestamp in the set- Specified by:
getMinDoublein interfaceTimeSet<Interval>- Returns:
- minimum timestamp, or null if the set is empty.
-
contains
public boolean contains(double timestamp)
Returns true if this set 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:TimeSetReturns true if this set containskey.
-
getIntervals
public double[] getIntervals()
Returns an array of all intervals in this set in a flat format.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
-
toArray
public Interval[] toArray()
Description copied from interface:TimeSetReturns an array of all keys in this set.This method may return a reference to the underlying array so clients should make a copy if the array is written to.
-
toPrimitiveArray
public Object toPrimitiveArray()
Description copied from interface:TimeSetReturns the same result asTimeSet.toArray()but in a primitive array if the underlying storage is in a primitive form.- Specified by:
toPrimitiveArrayin interfaceTimeSet<Interval>- Returns:
- array of all keys
-
clear
public void clear()
Description copied from interface:TimeSetEmpties this set.
-
toString
public String toString(TimeFormat timeFormat, org.joda.time.DateTimeZone timeZone)
Description copied from interface:TimeSetReturns this set as a string.
-
toString
public String toString(TimeFormat timeFormat)
Description copied from interface:TimeSetReturns this set as a string.
-
-