Commit | Line | Data |
---|---|---|
a79913eb FC |
1 | /******************************************************************************* |
2 | * Copyright (c) 2011 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made 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: | |
10 | * Patrick Tasse - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.experiment; | |
14 | ||
15 | import org.eclipse.linuxtools.tmf.trace.ITmfLocation; | |
16 | ||
17 | public class TmfLocationArray implements Comparable<TmfLocationArray>, Cloneable { | |
18 | public ITmfLocation<? extends Comparable<?>>[] locations; | |
19 | ||
20 | public TmfLocationArray(ITmfLocation<? extends Comparable<?>>[] locations) { | |
21 | this.locations = locations; | |
22 | } | |
23 | ||
24 | @SuppressWarnings({ "unchecked", "rawtypes" }) | |
25 | @Override | |
26 | public int compareTo(TmfLocationArray o) { | |
27 | for (int i = 0; i < locations.length; i++) { | |
28 | ITmfLocation<? extends Comparable> l1 = (ITmfLocation<? extends Comparable>) locations[i].getLocation(); | |
29 | ITmfLocation<? extends Comparable> l2 = (ITmfLocation<? extends Comparable>) o.locations[i].getLocation(); | |
30 | int result = l1.getLocation().compareTo(l2.getLocation()); | |
31 | if (result != 0) { | |
32 | return result; | |
33 | } | |
34 | } | |
35 | return 0; | |
36 | } | |
37 | ||
38 | /* (non-Javadoc) | |
39 | * @see java.lang.Object#clone() | |
40 | */ | |
41 | @Override | |
42 | protected TmfLocationArray clone() { | |
43 | ITmfLocation<? extends Comparable<?>>[] clones = (ITmfLocation<? extends Comparable<?>>[]) new ITmfLocation<?>[locations.length]; | |
44 | for (int i = 0; i < locations.length; i++) { | |
45 | clones[i] = locations[i].clone(); | |
46 | } | |
47 | return new TmfLocationArray(clones); | |
48 | } | |
49 | ||
50 | } | |
51 |