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 void
appendAll(VectorSTL<T> vector)
void
assign(VectorSTL<T> otherVector)
T
back()
IteratorSTL<T>
begin()
void
clear()
VectorSTL<T>
copy()
boolean
empty()
IteratorSTL<T>
end()
boolean
equals(java.lang.Object obj)
T
erase(int index)
IteratorSTL<T>
erase(IteratorSTL<T> it)
void
erase(IteratorSTL<T> start, IteratorSTL<T> end)
T
front()
T
get(int index)
void
insert(int index, T value)
void
insert(IteratorSTL<T> iterator, T value)
void
insert(IteratorSTL<T> pos, T[] list)
void
insertAll(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> void
merge(VectorSTL<K> v1, VectorSTL<K> v2, VectorSTL<K> destination)
static <K> void
merge(VectorSTL<K> v1, VectorSTL<K> v2, VectorSTL<K> destination, java.util.Comparator<K> comparator)
T
pop_back()
void
push_back(T value)
IteratorSTL<T>
rBegin()
IteratorSTL<T>
rEnd()
void
reserve(int capacity)
void
resize(int size, T value)
void
set(int index, T value)
void
set(IteratorSTL<T> iter, T value)
void
setBack(T value)
int
size()
void
sort()
Sorts the vector.void
sort(java.util.Comparator<T> comparator)
java.lang.String
toString()
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:
toString
in 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:
equals
in 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:
iterator
in 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)
-
-