IntervalTree.java.html
4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>IntervalTree.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">MTAS</a> > <a href="index.source.html" class="el_package">mtas.codec.tree</a> > <span class="el_source">IntervalTree.java</span></div><h1>IntervalTree.java</h1><pre class="source lang-java linenums">package mtas.codec.tree;
import java.util.ArrayList;
import mtas.codec.util.CodecSearchTree.MtasTreeHit;
/**
* The Class IntervalTree.
*
* @param <T> the generic type
* @param <N> the number type
*/
abstract public class IntervalTree<T, N extends IntervalTreeNode<T, N>> {
/** The root. */
protected N root;
/** The current. */
protected N current;
/**
* Instantiates a new interval tree.
*/
<span class="fc" id="L23"> public IntervalTree() {</span>
<span class="fc" id="L24"> root = null;</span>
<span class="fc" id="L25"> }</span>
/**
* Close.
*
* @return the n
*/
final public N close() {
<span class="pc bpc" id="L33" title="1 of 2 branches missed."> if (root == null) {</span>
<span class="nc" id="L34"> addRangeEmpty(0, 0);</span>
}
<span class="fc" id="L36"> return root;</span>
}
/**
* Adds the single point.
*
* @param position the position
* @param list the list
*/
abstract protected void addSinglePoint(int position,
ArrayList<MtasTreeHit<T>> list);
/**
* Adds the range.
*
* @param left the left
* @param right the right
* @param list the list
*/
abstract protected void addRange(int left, int right,
ArrayList<MtasTreeHit<T>> list);
/**
* Adds the range empty.
*
* @param left the left
* @param right the right
*/
abstract protected void addRangeEmpty(int left, int right);
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
<span class="nc" id="L71"> return printBalance(1, root);</span>
}
/**
* Prints the balance.
*
* @param p the p
* @param n the n
* @return the string
*/
final private String printBalance(Integer p, N n) {
<span class="nc" id="L82"> StringBuilder text = new StringBuilder();</span>
<span class="nc bnc" id="L83" title="All 2 branches missed."> if (n != null) {</span>
<span class="nc" id="L84"> text.append(printBalance((p + 1), n.leftChild));</span>
<span class="nc" id="L85"> String format = "%" + (3 * p) + "s";</span>
<span class="nc" id="L86"> text.append(String.format(format, ""));</span>
<span class="nc bnc" id="L87" title="All 2 branches missed."> if (n.left == n.right) {</span>
<span class="nc" id="L88"> text.append("[" + n.left + "] (" + n.max + ") : " + n.lists.size()</span>
+ " lists\n");
} else {
<span class="nc" id="L91"> text.append("[" + n.left + "-" + n.right + "] (" + n.max + ") : "</span>
<span class="nc" id="L92"> + n.lists.size() + " lists\n");</span>
}
<span class="nc" id="L94"> text.append(printBalance((p + 1), n.rightChild));</span>
}
<span class="nc" id="L96"> return text.toString();</span>
}
/**
* Gets the root.
*
* @return the root
*/
final public N getRoot() {
<span class="fc" id="L105"> return root;</span>
}
/**
* Gets the current.
*
* @return the current
*/
final public N getCurrent() {
<span class="nc" id="L114"> return current;</span>
}
/**
* Sets the current.
*
* @param node the new current
*/
final public void setCurrent(N node) {
<span class="nc" id="L123"> current = node;</span>
<span class="nc" id="L124"> }</span>
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.7.9.201702052155</span></div></body></html>