1 /*******************************************************************************
2 * Copyright (c) 2011-2012 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
.trace
.StreamInputReader
;
22 * <b><u>StreamInputReaderTimestampComparator</u></b>
24 * Compares two StreamInputReader by their timestamp (smaller comes before).
26 public class StreamInputReaderTimestampComparator
implements
27 Comparator
<StreamInputReader
>, Serializable
{
29 // ------------------------------------------------------------------------
31 // ------------------------------------------------------------------------
33 private static final long serialVersionUID
= 1066434959451875045L;
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
40 public int compare(StreamInputReader a
, StreamInputReader b
) {
41 // TODO: use unsigned comparison to avoid sign errors if needed
42 if (a
.getCurrentEvent() == null) {
45 if (b
.getCurrentEvent() == null) {
48 long ta
= a
.getCurrentEvent().timestamp
;
49 long tb
= b
.getCurrentEvent().timestamp
;