[ctf] Fix coding style issues in BitBuffer.
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.core / src / org / eclipse / linuxtools / tmf / core / util / TmfSortedArrayList.java
CommitLineData
12c155f5 1/*******************************************************************************
2f2265e2 2 * Copyright (c) 2011, 2012 Ericsson
063f0d27 3 *
12c155f5
FC
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
063f0d27 8 *
12c155f5
FC
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
6c13869b 13package org.eclipse.linuxtools.tmf.core.util;
12c155f5
FC
14
15import java.util.ArrayList;
16
17/**
2f2265e2 18 * Implementation of a sorted array list.
063f0d27 19 *
0283f7ff
FC
20 * @param <T> The array element type
21 *
2f2265e2 22 * @version 1.0
063f0d27 23 * @author Francois Chouinard
12c155f5
FC
24 */
25
26public class TmfSortedArrayList<T> extends ArrayList<T> {
27 private static final long serialVersionUID = 1L;
28
2f2265e2 29 /**
063f0d27
AM
30 * Inserts a new value in the list according to its sorted position.
31 *
32 * @param value A value to insert
2f2265e2 33 */
12c155f5
FC
34 @SuppressWarnings("unchecked")
35 public void insertSorted(T value) {
36 add(value);
37 Comparable<T> cmp = (Comparable<T>) value;
38 for (int pos = size() - 1; pos > 0 && cmp.compareTo(get(pos - 1)) < 0; pos--) {
39 T tmp = get(pos);
40 set(pos, get(pos - 1));
41 set(pos - 1, tmp);
42 }
43 }
44
45}
This page took 0.069453 seconds and 5 git commands to generate.