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 boolean
add(Interval interval)
Adds key to this set.void
clear()
Empties this set.boolean
contains(double timestamp)
Returns true if this set contains an interval that starts or ends attimestamp
.boolean
contains(Interval interval)
Returns true if this set containskey
.boolean
equals(Object obj)
double[]
getIntervals()
Returns an array of all intervals in this set in a flat format.int
hashCode()
boolean
isEmpty()
Returns true if this set is empty.boolean
remove(Interval interval)
Removes key from this set.int
size()
Returns the size of this set.Interval[]
toArray()
Returns an array of all keys in this set.Object
toPrimitiveArray()
Returns the same result asTimeSet.toArray()
but in a primitive array if the underlying storage is in a primtive form.String
toString()
String
toString(TimeFormat timeFormat)
Returns this set as a string.String
toString(TimeFormat timeFormat, 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:TimeSet
Adds key to this set.
-
remove
public boolean remove(Interval interval)
Description copied from interface:TimeSet
Removes key from this set.
-
size
public int size()
Description copied from interface:TimeSet
Returns the size of this set.
-
isEmpty
public boolean isEmpty()
Description copied from interface:TimeSet
Returns true if this 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:TimeSet
Returns 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:TimeSet
Returns 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:TimeSet
Returns the same result asTimeSet.toArray()
but in a primitive array if the underlying storage is in a primtive form.- Specified by:
toPrimitiveArray
in interfaceTimeSet<Interval>
- Returns:
- array of all keys
-
clear
public void clear()
Description copied from interface:TimeSet
Empties this set.
-
toString
public String toString(TimeFormat timeFormat, DateTimeZone timeZone)
Description copied from interface:TimeSet
Returns this set as a string.
-
toString
public String toString(TimeFormat timeFormat)
Description copied from interface:TimeSet
Returns this set as a string.
-
-