ctf: Fix lost events in a more elegant way
[deliverable/tracecompass.git] / org.eclipse.linuxtools.ctf.core / src / org / eclipse / linuxtools / internal / ctf / core / trace / StreamInputReaderComparator.java
1 /*******************************************************************************
2 * Copyright (c) 2011-2012 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.linuxtools.internal.ctf.core.trace;
14
15 import java.io.Serializable;
16 import java.util.Comparator;
17
18 import org.eclipse.linuxtools.ctf.core.trace.StreamInputReader;
19
20
21 /**
22 * <b><u>StreamInputReaderComparator</u></b>
23 * <p>
24 * TODO Implement me. Please.
25 */
26 public class StreamInputReaderComparator implements
27 Comparator<StreamInputReader>, Serializable {
28
29 // ------------------------------------------------------------------------
30 // Constants
31 // ------------------------------------------------------------------------
32
33 private static final long serialVersionUID = 7477206132343139753L;
34
35 // ------------------------------------------------------------------------
36 // Operations
37 // ------------------------------------------------------------------------
38
39 @Override
40 public int compare(StreamInputReader a, StreamInputReader b) {
41 // TODO: use unsigned comparison to avoid sign errors if needed
42 long ta = a.getCurrentEvent().getTimestamp();
43 long tb = b.getCurrentEvent().getTimestamp();
44
45 if (ta < tb) {
46 return -1;
47 } else if (ta > tb) {
48 return 1;
49 } else {
50 return 0;
51 }
52 }
53
54 }
This page took 0.041239 seconds and 5 git commands to generate.