public class WeightedList<E>
extends java.lang.Object
implements java.util.Collection<E>
Constructor and Description |
---|
WeightedList() |
WeightedList(int initialCapacity) |
Modifier and Type | Method and Description |
---|---|
boolean |
add(E e) |
void |
add(E e,
double weight)
Adds
e after the last existing entry that has a weight equal or higher than weight . |
boolean |
addAll(java.util.Collection<? extends E> c) |
boolean |
addAll(WeightedList<E> sourceList) |
void |
addFirst(E e,
double weight)
Adds
e before the first existing entry that has a weight equal or higher than weight . |
void |
addLast(E e,
double weight)
Adds
e after the last existing entry that has a weight equal or higher than weight . |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> c) |
E |
get(int index) |
double |
getWeight(int index) |
int |
indexOf(java.lang.Object e) |
boolean |
isEmpty() |
java.util.Iterator<E> |
iterator() |
boolean |
remove(java.lang.Object object)
Removes the first entry that is equal to
object |
boolean |
remove(java.lang.Object object,
double weight)
Removes the first entry that is equal to
object and has the specified weight. |
boolean |
removeAll(java.util.Collection<?> c) |
boolean |
retainAll(java.util.Collection c) |
int |
size() |
java.lang.Object[] |
toArray() |
java.lang.Object[] |
toArray(java.lang.Object[] a) |
public WeightedList()
public WeightedList(int initialCapacity)
public void add(E e, double weight)
e
after the last existing entry that has a weight equal or higher than weight
.
This method is equivalent to addLast(E, double)
e
- The entry to addweight
- The entry weightpublic void addFirst(E e, double weight)
e
before the first existing entry that has a weight equal or higher than weight
.e
- The entry to addweight
- The entry weightpublic void addLast(E e, double weight)
e
after the last existing entry that has a weight equal or higher than weight
.e
- The entry to addweight
- The entry weightpublic boolean remove(java.lang.Object object)
object
remove
in interface java.util.Collection<E>
object
- the object to removepublic boolean remove(java.lang.Object object, double weight)
object
and has the specified weight.object
- the object to removeweight
- the corresponding weightpublic java.util.Iterator<E> iterator()
public E get(int index)
public int size()
size
in interface java.util.Collection<E>
public void clear()
clear
in interface java.util.Collection<E>
public boolean isEmpty()
isEmpty
in interface java.util.Collection<E>
public java.lang.Object[] toArray()
toArray
in interface java.util.Collection<E>
public int indexOf(java.lang.Object e)
public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection<E>
public boolean addAll(java.util.Collection<? extends E> c)
addAll
in interface java.util.Collection<E>
public boolean addAll(WeightedList<E> sourceList)
public boolean containsAll(java.util.Collection<?> c)
containsAll
in interface java.util.Collection<E>
public boolean removeAll(java.util.Collection<?> c)
removeAll
in interface java.util.Collection<E>
public boolean retainAll(java.util.Collection c)
retainAll
in interface java.util.Collection<E>
public java.lang.Object[] toArray(java.lang.Object[] a)
toArray
in interface java.util.Collection<E>
public double getWeight(int index)