1 /*******************************************************************************
2 * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alexandre Montplaisir - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.segmentstore
.core
;
15 import java
.util
.Collection
;
16 import java
.util
.Collections
;
17 import java
.util
.Comparator
;
18 import java
.util
.Iterator
;
19 import java
.util
.List
;
21 import org
.eclipse
.jdt
.annotation
.NonNull
;
23 import com
.google
.common
.collect
.Lists
;
26 * Interface for segment-storing backends.
29 * The type of {@link ISegment} element that will be stored in this
32 * @author Alexandre Montplaisir
34 public interface ISegmentStore
<E
extends ISegment
> extends Collection
<E
> {
40 * The desired order for the returned iterator
41 * @return An iterator over all the segments in the store in the desired order
44 default Iterable
<E
> iterator(Comparator
<ISegment
> order
){
45 return getIntersectingElements(Long
.MIN_VALUE
, Long
.MAX_VALUE
, order
);
49 * Retrieve all elements that inclusively cross the given position.
52 * The target position. This would represent a timestamp, if the
53 * tree's X axis represents time.
54 * @return The intervals that cross this position
56 default Iterable
<E
> getIntersectingElements(long position
){
57 return getIntersectingElements(position
, position
);
61 * Retrieve all elements that inclusively cross the given position, sorted
62 * in the specified order.
65 * The target position. This would represent a timestamp, if the
66 * tree's X axis represents time.
68 * The desired order for the returned iterator
69 * @return The intervals that cross this position
72 default Iterable
<E
> getIntersectingElements(long position
, Comparator
<ISegment
> order
) {
73 return getIntersectingElements(position
, position
, order
);
77 * Retrieve all elements that inclusively cross another segment. We define
78 * this target segment by its start and end positions.
80 * This effectively means, all elements that respect *both* conditions:
83 * <li>Their end is after the 'start' parameter</li>
84 * <li>Their start is before the 'end' parameter</li>
88 * The target start position
90 * The target end position
91 * @return The elements overlapping with this segment
93 Iterable
<E
> getIntersectingElements(long start
, long end
);
96 * Retrieve all elements that inclusively cross another segment, sorted in
97 * the specified order. We define this target segment by its start and end
101 * The target start position
103 * The target end position
105 * The desired order for the returned iterator
106 * @return The intervals that cross this position
109 default Iterable
<E
> getIntersectingElements(long start
, long end
, Comparator
<ISegment
> order
){
110 List
<E
> list
= Lists
.newArrayList(getIntersectingElements(start
, end
));
111 return new Iterable
<@NonNull E
>() {
113 public Iterator
<@NonNull E
> iterator() {
114 Collections
.sort(list
, order
);
115 return list
.iterator();
121 * Dispose the data structure and release any system resources associated
127 * Method to close off the segment store. This happens for example when we
128 * are done reading an off-line trace. Implementers can use this method to
129 * save the segment store on disk
132 * Whether to delete any file that was created while building the
135 default void close(boolean deleteFiles
) {
This page took 0.033133 seconds and 5 git commands to generate.