1 /*******************************************************************************
2 * Copyright (c) 2011, 2014 Ericsson, Ecole Polytechnique de Montreal and others
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
9 * Contributors: Matthew Khouzam - Initial API and implementation
10 * Contributors: Simon Marchi - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.ctf
.core
.trace
;
15 import java
.io
.Serializable
;
16 import java
.util
.Comparator
;
18 import org
.eclipse
.tracecompass
.ctf
.core
.event
.EventDefinition
;
19 import org
.eclipse
.tracecompass
.ctf
.core
.trace
.CTFStreamInputReader
;
22 * <b><u>StreamInputReaderTimestampComparator</u></b>
24 * Compares two StreamInputReader by their timestamp (smaller comes before).
26 public class StreamInputReaderTimestampComparator
implements
27 Comparator
<CTFStreamInputReader
>, Serializable
{
29 // ------------------------------------------------------------------------
31 // ------------------------------------------------------------------------
33 private static final long serialVersionUID
= 1066434959451875045L;
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
40 * @throws NullPointerException
41 * If any {@link CTFStreamInputReader} parameter is null, of if any
42 * of them does not contain a current event.
45 public int compare(CTFStreamInputReader a
, CTFStreamInputReader b
) {
46 EventDefinition event_a
= a
.getCurrentEvent();
47 EventDefinition event_b
= b
.getCurrentEvent();
49 long ta
= event_a
.getTimestamp();
50 long tb
= event_b
.getTimestamp();
51 return Utils
.unsignedCompare(ta
, tb
);