Top Description Inners Fields Constructors Methods
com.calendarfx.model

pack-priv Class IntervalTree<E extends Entry<?>>

extends Object
Class Inheritance
Type Parameters
<E>
the entry type
Imports
java.time.Instant, .LocalTime, .ZonedDateTime, java.util.ArrayList, .Collection, .HashSet, .Objects, .Set

An interval tree implementation to store entries based on their start and end time.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private static class
IntervalTree.TreeEntry<V>

Internal Entry class.

Field Summary

Modifier and TypeField and Description
private static final boolean
private final Set<String>
private static final boolean
private IntervalTree.TreeEntry<E>
private int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final boolean
add(E entry)

private IntervalTree.TreeEntry<E>
addEntry(E entry)

private boolean
checkPHigh(IntervalTree.TreeEntry<E> n, long pHigh)

private boolean
checkPLow(IntervalTree.TreeEntry<E> n, long pLow)

public final void
private static <V> boolean
colorOf(IntervalTree.TreeEntry<V> p)

Balancing operations.

private static int
compareLongs(long val1, long val2)

public final boolean

Returns:

true if the entry is a member of this tree
contains
(E
the entry to check
entry
)

Method to determine if the interval tree contains the given entry.

private void
deleteEntry(IntervalTree.TreeEntry<E> p)

Delete node p, and then rebalance the tree.

private void
private void
private void
public final Instant
private long
private IntervalTree.TreeEntry<E>

Returns:

appropriate entry, or null if not found
getEntry
(Entry<?>
the calendar entry
entry
)

Method to find entry by period.

private long
private long
getHigh(Entry<?> entry)

public final Collection<E>
public final Instant
private long
private long
private long
getLow(Entry<?> entry)

private static <V> IntervalTree.TreeEntry<V>
private static <V> IntervalTree.TreeEntry<V>
public final boolean

Returns:

true if the entry was a member of this tree
remove
(E
the entry to remove
entry
)

Method to remove period/key object from tree.

public final Collection<E>
private static <V> IntervalTree.TreeEntry<V>
private void
private void
private void
private static <V> void
setColor(IntervalTree.TreeEntry<V> p, boolean c)

public final long
size()

private static <
the value type
V
>
IntervalTree.TreeEntry<V>
successor(IntervalTree.TreeEntry<V> t)

Returns the successor of the specified Entry, or null if no such.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BLACKback to summary
private static final boolean BLACK
entryIDsback to summary
private final Set<String> entryIDs
REDback to summary
private static final boolean RED
rootback to summary
private IntervalTree.TreeEntry<E> root
treeSizeback to summary
private int treeSize

Constructor Detail

IntervalTreeback to summary
pack-priv IntervalTree()

Method Detail

addback to summary
public final boolean add(E entry)
addEntryback to summary
private IntervalTree.TreeEntry<E> addEntry(E entry)
checkPHighback to summary
private boolean checkPHigh(IntervalTree.TreeEntry<E> n, long pHigh)
checkPLowback to summary
private boolean checkPLow(IntervalTree.TreeEntry<E> n, long pLow)
clearback to summary
public final void clear()
colorOfback to summary
private static <V> boolean colorOf(IntervalTree.TreeEntry<V> p)

Balancing operations. Implementations of rebalancings during insertion and deletion are slightly different than the CLR version. Rather than using dummy nilnodes, we use a set of accessors that deal properly with null. They are used to avoid messiness surrounding nullness checks in the main algorithms.

compareLongsback to summary
private static int compareLongs(long val1, long val2)
containsback to summary
public final boolean contains(E entry)

Method to determine if the interval tree contains the given entry.

Parameters
entry:E

the entry to check

Returns:boolean

true if the entry is a member of this tree

deleteEntryback to summary
private void deleteEntry(IntervalTree.TreeEntry<E> p)

Delete node p, and then rebalance the tree.

fixAfterDeletionback to summary
private void fixAfterDeletion(IntervalTree.TreeEntry<E> x)
fixAfterInsertionback to summary
private void fixAfterInsertion(IntervalTree.TreeEntry<E> x)
fixUpMaxHighback to summary
private void fixUpMaxHigh(IntervalTree.TreeEntry<E> entry)
getEarliestTimeUsedback to summary
public final Instant getEarliestTimeUsed()
getEarliestTimeUsedback to summary
private long getEarliestTimeUsed(IntervalTree.TreeEntry<E> entry)
getEntryback to summary
private IntervalTree.TreeEntry<E> getEntry(Entry<?> entry)

Method to find entry by period. Period start, period end and object key are used to identify each entry.

Parameters
entry:Entry<?>

the calendar entry

Returns:IntervalTree.TreeEntry<E>

appropriate entry, or null if not found

getHighback to summary
private long getHigh(IntervalTree<E>.TimeInterval interval)
getHighback to summary
private long getHigh(Entry<?> entry)
getIntersectingObjectsback to summary
public final Collection<E> getIntersectingObjects(Instant start, Instant end)
getLatestTimeUsedback to summary
public final Instant getLatestTimeUsed()
getLatestTimeUsedback to summary
private long getLatestTimeUsed(IntervalTree.TreeEntry<E> entry)
getLowback to summary
private long getLow(IntervalTree<E>.TimeInterval obj)
getLowback to summary
private long getLow(Entry<?> entry)
leftOfback to summary
private static <V> IntervalTree.TreeEntry<V> leftOf(IntervalTree.TreeEntry<V> p)
parentOfback to summary
private static <V> IntervalTree.TreeEntry<V> parentOf(IntervalTree.TreeEntry<V> p)
removeback to summary
public final boolean remove(E entry)

Method to remove period/key object from tree. Entry to delete will be found by period and key values of given parameter p (not by given object reference).

Parameters
entry:E

the entry to remove

Returns:boolean

true if the entry was a member of this tree

removePeriodback to summary
public final Collection<E> removePeriod(Instant start, Instant end)
rightOfback to summary
private static <V> IntervalTree.TreeEntry<V> rightOf(IntervalTree.TreeEntry<V> p)
rotateLeftback to summary
private void rotateLeft(IntervalTree.TreeEntry<E> p)
rotateRightback to summary
private void rotateRight(IntervalTree.TreeEntry<E> p)
searchIntersectingback to summary
private void searchIntersecting(IntervalTree.TreeEntry<E> entry, IntervalTree<E>.TimeInterval timeInterval, Collection<E> result)
setColorback to summary
private static <V> void setColor(IntervalTree.TreeEntry<V> p, boolean c)
sizeback to summary
public final long size()
successorback to summary
private static <V> IntervalTree.TreeEntry<V> successor(IntervalTree.TreeEntry<V> t)

Returns the successor of the specified Entry, or null if no such.

Parameters
<V>
the value type
com.calendarfx.model back to summary

private Class IntervalTree.TimeInterval

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Instant
private final Instant

Constructor Summary

AccessConstructor and Description
public
TimeInterval(Instant startTime, Instant endTime)

Method Summary

Modifier and TypeMethod and Description
public Instant
public Instant
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

endTimeback to summary
private final Instant endTime
startTimeback to summary
private final Instant startTime

Constructor Detail

TimeIntervalback to summary
public TimeInterval(Instant startTime, Instant endTime)

Method Detail

getEndTimeback to summary
public Instant getEndTime()
getStartTimeback to summary
public Instant getStartTime()
com.calendarfx.model back to summary

private final Class IntervalTree.TreeEntry<V>

extends Object
Class Inheritance

Internal Entry class.
Author
koop

Field Summary

Modifier and TypeField and Description
private boolean
private long
private IntervalTree.TreeEntry<V>
private long
private long
private IntervalTree.TreeEntry<V>
private IntervalTree.TreeEntry<V>
private V

Constructor Summary

AccessConstructor and Description
pack-priv
TreeEntry(long low, long high, V value, IntervalTree.TreeEntry<V> parent)

Make a new cell with given key, value, and parent, and with null child links, and BLACK color.

Method Summary

Modifier and TypeMethod and Description
public IntervalTree.TreeEntry<V>
public IntervalTree.TreeEntry<V>
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

colorback to summary
private boolean color
highback to summary
private long high
leftback to summary
private IntervalTree.TreeEntry<V> left
lowback to summary
private long low
maxHighback to summary
private long maxHigh
parentback to summary
private IntervalTree.TreeEntry<V> parent
rightback to summary
private IntervalTree.TreeEntry<V> right
valueback to summary
private V value

Constructor Detail

TreeEntryback to summary
pack-priv TreeEntry(long low, long high, V value, IntervalTree.TreeEntry<V> parent)

Make a new cell with given key, value, and parent, and with null child links, and BLACK color.

Method Detail

getLeftback to summary
public IntervalTree.TreeEntry<V> getLeft()
getRightback to summary
public IntervalTree.TreeEntry<V> getRight()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override