1 /*******************************************************************************
2 * Copyright (c) 2011, 2013 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
.linuxtools
.internal
.ctf
.core
.trace
;
15 import java
.io
.Serializable
;
16 import java
.util
.Comparator
;
18 import org
.eclipse
.linuxtools
.ctf
.core
.event
.EventDefinition
;
19 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.CTFStreamInputReader
;
20 import org
.eclipse
.linuxtools
.ctf
.core
.trace
.Utils
;
23 * <b><u>StreamInputReaderTimestampComparator</u></b>
25 * Compares two StreamInputReader by their timestamp (smaller comes before).
27 public class StreamInputReaderTimestampComparator
implements
28 Comparator
<CTFStreamInputReader
>, Serializable
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
34 private static final long serialVersionUID
= 1066434959451875045L;
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
41 * @throws NullPointerException
42 * If any {@link CTFStreamInputReader} parameter is null, of if any
43 * of them does not contain a current event.
46 public int compare(CTFStreamInputReader a
, CTFStreamInputReader b
) {
47 EventDefinition event_a
= a
.getCurrentEvent();
48 EventDefinition event_b
= b
.getCurrentEvent();
50 long ta
= event_a
.getTimestamp();
51 long tb
= event_b
.getTimestamp();
52 return Utils
.unsignedCompare(ta
, tb
);