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
.ctf
.core
.trace
;
15 import java
.io
.Serializable
;
16 import java
.util
.Comparator
;
19 * <b><u>StreamInputReaderTimestampComparator</u></b>
21 * Compares two StreamInputReader by their timestamp (smaller comes before).
23 public class StreamInputReaderTimestampComparator
implements
24 Comparator
<StreamInputReader
>, Serializable
{
26 // ------------------------------------------------------------------------
28 // ------------------------------------------------------------------------
30 private static final long serialVersionUID
= 1066434959451875045L;
32 // ------------------------------------------------------------------------
34 // ------------------------------------------------------------------------
37 public int compare(StreamInputReader a
, StreamInputReader b
) {
38 // TODO: use unsigned comparison to avoid sign errors if needed
39 if (a
.getCurrentEvent() == null) {
42 if (b
.getCurrentEvent() == null) {
45 long ta
= a
.getCurrentEvent().timestamp
;
46 long tb
= b
.getCurrentEvent().timestamp
;