a93d4a291fb51afd867283589557b6d252c36d98
1 /*******************************************************************************
2 * Copyright (c) 2011, 2012 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.core
.util
;
15 import java
.util
.ArrayList
;
18 * Implementation of a sorted array list.
20 * @param <T> The array element type
23 * @author Francois Chouinard
26 public class TmfSortedArrayList
<T
> extends ArrayList
<T
> {
27 private static final long serialVersionUID
= 1L;
30 * Inserts a new value in the list according to its sorted position.
32 * @param value A value to insert
34 @SuppressWarnings("unchecked")
35 public void insertSorted(T value
) {
37 Comparable
<T
> cmp
= (Comparable
<T
>) value
;
38 for (int pos
= size() - 1; pos
> 0 && cmp
.compareTo(get(pos
- 1)) < 0; pos
--) {
40 set(pos
, get(pos
- 1));
This page took 0.031741 seconds and 4 git commands to generate.