Package com.actelion.research.util
Class SortedList<T extends java.lang.Comparable<? super T>>
- java.lang.Object
-
- com.actelion.research.util.SortedList<T>
-
- Direct Known Subclasses:
UniqueList
public class SortedList<T extends java.lang.Comparable<? super T>> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description SortedList()
SortedList(java.util.Comparator comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
add(T object)
Adds object to the list provided that it doesn't contain an object being considered equal by compareTo().boolean
contains(T object)
boolean
equals(SortedList<T> s)
T
get(int index)
Returns object at given index, or null if index==-1int
getIndex(T object)
Returns the position index of object in the sorted list.int
getIndexAboveEqual(T object)
If object is not member of this list, returns potential insert index.int
getIndexBelowEqual(T object)
If object is not member of this list, returns potential insert index.int
getIndexOrInsertIndex(T object)
Returns the position index of object in the sorted list.void
remove(int index)
void
removeAll()
int
size()
T[]
toArray(T[] e)
-
-
-
Method Detail
-
contains
public boolean contains(T object)
-
equals
public boolean equals(SortedList<T> s)
-
getIndex
public int getIndex(T object)
Returns the position index of object in the sorted list. If object is not in the list, -1 is returned.- Parameters:
object
-- Returns:
-
getIndexOrInsertIndex
public int getIndexOrInsertIndex(T object)
Returns the position index of object in the sorted list. If object is not in the list, -(insertIndex+1) is returned with insertIndex being that position where object would need to be inserted to keep a correct sort order.- Parameters:
object
-- Returns:
-
getIndexBelowEqual
public int getIndexBelowEqual(T object)
If object is not member of this list, returns potential insert index. If object is member of this list, return list index of object.- Parameters:
object
-- Returns:
- list index or insert index
-
getIndexAboveEqual
public int getIndexAboveEqual(T object)
If object is not member of this list, returns potential insert index. If object is member of this list, return list index of object incremented by one.- Parameters:
object
-- Returns:
- list index or insert index
-
add
public int add(T object)
Adds object to the list provided that it doesn't contain an object being considered equal by compareTo().- Parameters:
object
-- Returns:
- object's list index, no matter wether it was already in the list or after addition
-
size
public int size()
-
get
public T get(int index)
Returns object at given index, or null if index==-1- Parameters:
index
- existing index or < 0- Returns:
- object or null
-
remove
public void remove(int index)
-
removeAll
public void removeAll()
-
-