Package generic.stl
Class VectorSTL<T>
- java.lang.Object
-
- generic.stl.VectorSTL<T>
-
- All Implemented Interfaces:
java.lang.Iterable<T>
public class VectorSTL<T> extends java.lang.Object implements java.lang.Iterable<T>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendAll(VectorSTL<T> vector)voidassign(VectorSTL<T> otherVector)Tback()IteratorSTL<T>begin()voidclear()VectorSTL<T>copy()booleanempty()IteratorSTL<T>end()booleanequals(java.lang.Object obj)Terase(int index)IteratorSTL<T>erase(IteratorSTL<T> it)voiderase(IteratorSTL<T> start, IteratorSTL<T> end)Tfront()Tget(int index)voidinsert(int index, T value)voidinsert(IteratorSTL<T> iterator, T value)voidinsert(IteratorSTL<T> pos, T[] list)voidinsertAll(IteratorSTL<T> pos, VectorSTL<T> vector)java.util.Iterator<T>iterator()IteratorSTL<T>lower_bound(T key)Returns an iterator postioned at the item in the vector that is the smallest key less or equal than the given key.IteratorSTL<T>lower_bound(T key, java.util.Comparator<T> comparator)Returns an iterator postioned at the item in the vector that is the smallest key less or equal than the given key.static <K> voidmerge(VectorSTL<K> v1, VectorSTL<K> v2, VectorSTL<K> destination)static <K> voidmerge(VectorSTL<K> v1, VectorSTL<K> v2, VectorSTL<K> destination, java.util.Comparator<K> comparator)Tpop_back()voidpush_back(T value)IteratorSTL<T>rBegin()IteratorSTL<T>rEnd()voidreserve(int capacity)voidresize(int size, T value)voidset(int index, T value)voidset(IteratorSTL<T> iter, T value)voidsetBack(T value)intsize()voidsort()Sorts the vector.voidsort(java.util.Comparator<T> comparator)java.lang.StringtoString()IteratorSTL<T>upper_bound(T key)Returns an iterator postioned at the item in the vector that is the smallest key less than the given key.IteratorSTL<T>upper_bound(T key, java.util.Comparator<T> comparator)Returns an iterator postioned at the item in the vector that is the smallest key less than the given key.
-
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
reserve
public void reserve(int capacity)
-
begin
public IteratorSTL<T> begin()
-
end
public IteratorSTL<T> end()
-
rBegin
public IteratorSTL<T> rBegin()
-
rEnd
public IteratorSTL<T> rEnd()
-
clear
public void clear()
-
size
public int size()
-
empty
public boolean empty()
-
get
public T get(int index)
-
front
public T front()
-
back
public T back()
-
setBack
public void setBack(T value)
-
push_back
public void push_back(T value)
-
pop_back
public T pop_back()
-
insert
public void insert(int index, T value)
-
insertAll
public void insertAll(IteratorSTL<T> pos, VectorSTL<T> vector)
-
insert
public void insert(IteratorSTL<T> iterator, T value)
-
set
public void set(int index, T value)
-
set
public void set(IteratorSTL<T> iter, T value)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
erase
public T erase(int index)
-
erase
public IteratorSTL<T> erase(IteratorSTL<T> it)
-
erase
public void erase(IteratorSTL<T> start, IteratorSTL<T> end)
-
sort
public void sort()
Sorts the vector. To use this method T must be comparable.- Throws:
java.lang.UnsupportedOperationException- if T is not comparable;
-
sort
public void sort(java.util.Comparator<T> comparator)
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<T>
-
lower_bound
public IteratorSTL<T> lower_bound(T key, java.util.Comparator<T> comparator)
Returns an iterator postioned at the item in the vector that is the smallest key less or equal than the given key. This method assumes the vector is sorted in ascending order.- Parameters:
key- the key for which to find the lower bound- Returns:
- an iterator postioned at the item in the vector that is the smallest key less or equal than the given key.
- Throws:
java.lang.UnsupportedOperationException- if T is not comparable
-
lower_bound
public IteratorSTL<T> lower_bound(T key)
Returns an iterator postioned at the item in the vector that is the smallest key less or equal than the given key. This method assumes the vector is sorted in ascending order.- Parameters:
key- the key for which to find the lower bound- Returns:
- an iterator postioned at the item in the vector that is the smallest key less or equal than the given key.
-
upper_bound
public IteratorSTL<T> upper_bound(T key)
Returns an iterator postioned at the item in the vector that is the smallest key less than the given key. This method assumes the vector is sorted in ascending order.- Parameters:
key- the key for which to find the upper bound- Returns:
- an iterator postioned at the item in the vector that is the smallest key less than the given key.
- Throws:
java.lang.UnsupportedOperationException- if T is not comparable
-
upper_bound
public IteratorSTL<T> upper_bound(T key, java.util.Comparator<T> comparator)
Returns an iterator postioned at the item in the vector that is the smallest key less than the given key. This method assumes the vector is sorted in ascending order.- Parameters:
key- the key for which to find the upper bound- Returns:
- an iterator postioned at the item in the vector that is the smallest key less than the given key.
- Throws:
java.lang.UnsupportedOperationException- if T is not comparable
-
merge
public static <K> void merge(VectorSTL<K> v1, VectorSTL<K> v2, VectorSTL<K> destination, java.util.Comparator<K> comparator)
-
resize
public void resize(int size, T value)
-
insert
public void insert(IteratorSTL<T> pos, T[] list)
-
-