Class VectorUtils


  • public class VectorUtils
    extends java.lang.Object
    This class provides "empty" and "unmodifiable" wrappers for the Vector class. The functionality is similar the Collections class and mostly copy-paste from the class. Unfortunately, the standard Collections class does not provides wrappers for the outdated Vector class.
    See Also:
    Collections
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Vector EMPTY_VECTOR
      The empty vector (immutable).
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.Vector<T> emptyVector()
      Returns an empty vector (immutable).
      static <T> java.util.Vector<T> unmodifiableVector​(java.util.Vector<? extends T> vector)
      Returns an unmodifiable view of the specified vector.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMPTY_VECTOR

        public static final java.util.Vector EMPTY_VECTOR
        The empty vector (immutable).
        See Also:
        emptyVector()
    • Method Detail

      • unmodifiableVector

        public static <T> java.util.Vector<T> unmodifiableVector​(java.util.Vector<? extends T> vector)
        Returns an unmodifiable view of the specified vector. This method allows modules to provide users with "read-only" access to internal vectors. Query operations on the returned vector "read through" to the specified vector, and attempts to modify the returned vector, whether direct or via its iterator, result in an UnsupportedOperationException.

        Type Parameters:
        T - the class of the objects in the vector
        Parameters:
        vector - the vector for which an unmodifiable view is to be returned.
        Returns:
        an unmodifiable view of the specified vector.
      • emptyVector

        public static final <T> java.util.Vector<T> emptyVector()
        Returns an empty vector (immutable).

        This example illustrates the type-safe way to obtain an empty vector:

             Vector<String> s = VectorUtils.emptyVector();
         
        Type Parameters:
        T - type of elements, if there were any, in the vector
        Returns:
        an empty immutable vector
        See Also:
        EMPTY_VECTOR