ctf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / ctf / org.eclipse.tracecompass.ctf.core / src / org / eclipse / tracecompass / internal / ctf / core / trace / StreamInputReaderTimestampComparator.java
1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.internal.ctf.core.trace;
14
15 import java.io.Serializable;
16 import java.util.Comparator;
17
18 import org.eclipse.tracecompass.ctf.core.event.EventDefinition;
19 import org.eclipse.tracecompass.ctf.core.trace.CTFStreamInputReader;
20
21 /**
22 * <b><u>StreamInputReaderTimestampComparator</u></b>
23 * <p>
24 * Compares two StreamInputReader by their timestamp (smaller comes before).
25 */
26 public class StreamInputReaderTimestampComparator implements
27 Comparator<CTFStreamInputReader>, Serializable {
28
29 // ------------------------------------------------------------------------
30 // Constants
31 // ------------------------------------------------------------------------
32
33 private static final long serialVersionUID = 1066434959451875045L;
34
35 // ------------------------------------------------------------------------
36 // Operations
37 // ------------------------------------------------------------------------
38
39 /**
40 * @throws NullPointerException
41 * If any {@link CTFStreamInputReader} parameter is null, of if any
42 * of them does not contain a current event.
43 */
44 @Override
45 public int compare(CTFStreamInputReader a, CTFStreamInputReader b) {
46 EventDefinition event_a = a.getCurrentEvent();
47 EventDefinition event_b = b.getCurrentEvent();
48
49 long ta = event_a.getTimestamp();
50 long tb = event_b.getTimestamp();
51 return Utils.unsignedCompare(ta, tb);
52 }
53
54 }
This page took 0.031813 seconds and 6 git commands to generate.