JAL-3383 JAL-3397 JAL-3253-applet IntervalStore options
[jalview.git] / unused / nonc / IntervalStoreI.java
1 /*
2 BSD 3-Clause License
3
4 Copyright (c) 2018, Mungo Carstairs
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 * Redistributions of source code must retain the above copyright notice, this
11   list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright notice,
14   this list of conditions and the following disclaimer in the documentation
15   and/or other materials provided with the distribution.
16
17 * Neither the name of the copyright holder nor the names of its
18   contributors may be used to endorse or promote products derived from
19   this software without specific prior written permission.
20
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 package intervalstore.api;
33
34 import java.util.Collection;
35 import java.util.List;
36
37 import intervalstore.impl.NCList;
38
39 public interface IntervalStoreI<T extends IntervalI> extends Collection<T>
40 {
41
42   /**
43    * Returns a (possibly empty) list of items whose extent overlaps the given
44    * range
45    * 
46    * @param from
47    *          start of overlap range (inclusive)
48    * @param to
49    *          end of overlap range (inclusive)
50    * @return
51    */
52   List<T> findOverlaps(long from, long to);
53
54   /**
55    * Ensures that the IntervalStore is ready for findOverlap.
56    * 
57    * @return true iff the data held satisfy the rules of construction of an
58    *         IntervalStore.
59    * 
60    */
61   boolean isValid();
62
63   /**
64    * Answers the level of nesting of intervals in the store, as
65    * <ul>
66    * <li>0 if the store is empty</li>
67    * <li>1 if all intervals are 'top level' (non nested)</li>
68    * <li>else 1 plus the depth of the enclosed NCList</li>
69    * </ul>
70    * 
71    * @return
72    * @see NCList#getDepth()
73    */
74
75   int getDepth();
76
77   /**
78    * Return the number of top-level (not-contained) intervals.
79    * 
80    * @return
81    */
82   int getWidth();
83
84   List<T> findOverlaps(long start, long end, List<T> result);
85
86   String prettyPrint();
87
88   /**
89    * Resort and rebuild links.
90    * 
91    * @return
92    */
93   boolean revalidate();
94
95   IntervalI get(int i);
96
97 }