Package generic.stl

Class VectorSTL<T>

  • All Implemented Interfaces:
    java.lang.Iterable<T>

    public class VectorSTL<T>
    extends java.lang.Object
    implements java.lang.Iterable<T>
    • Constructor Detail

      • VectorSTL

        public VectorSTL()
      • VectorSTL

        public VectorSTL​(int initialCapacity)
      • VectorSTL

        public VectorSTL​(int initialCapacity,
                         T value)
      • VectorSTL

        public VectorSTL​(VectorSTL<T> other)
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • reserve

        public void reserve​(int capacity)
      • 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)
      • insert

        public void insert​(IteratorSTL<T> iterator,
                           T value)
      • set

        public void set​(int index,
                        T value)
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • erase

        public T erase​(int index)
      • 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 interface java.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)
      • assign

        public void assign​(VectorSTL<T> otherVector)