Package generic.stl

Class VectorSTL<T>

java.lang.Object
generic.stl.VectorSTL<T>
All Implemented Interfaces:
Iterable<T>

public class VectorSTL<T> extends Object implements Iterable<T>
  • Constructor Details

    • VectorSTL

      public VectorSTL()
    • VectorSTL

      public VectorSTL(int initialCapacity)
    • VectorSTL

      public VectorSTL(int initialCapacity, T value)
    • VectorSTL

      public VectorSTL(VectorSTL<T> other)
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class 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)
    • appendAll

      public void appendAll(VectorSTL<T> vector)
    • 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(Object obj)
      Overrides:
      equals in class 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:
      UnsupportedOperationException - if T is not comparable;
    • sort

      public void sort(Comparator<T> comparator)
    • copy

      public VectorSTL<T> copy()
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T>
    • lower_bound

      public IteratorSTL<T> lower_bound(T key, 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:
      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:
      UnsupportedOperationException - if T is not comparable
    • upper_bound

      public IteratorSTL<T> upper_bound(T key, 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:
      UnsupportedOperationException - if T is not comparable
    • merge

      public static <K> void merge(VectorSTL<K> v1, VectorSTL<K> v2, VectorSTL<K> destination)
    • merge

      public static <K> void merge(VectorSTL<K> v1, VectorSTL<K> v2, VectorSTL<K> destination, Comparator<K> comparator)
    • resize

      public void resize(int size, T value)
    • insert

      public void insert(IteratorSTL<T> pos, T[] list)
    • assign

      public void assign(VectorSTL<T> otherVector)