code: @SuppressWarnings("unchecked")
      public static <T extends Vector> T instanceOf(T vector) {
          // Check for known vector types to avoid reflection overhead
          if (vector instanceof CompactSparseIntegerVector) {
              return (T)(new CompactSparseIntegerVector(vector.length()));
          }
          // Remaining cases of vector types is being left unfinished until the
          // vector name refactoring is finished.  -jurgens 12/7/09
          else {
              try {
                  Class<T> clazz = (Class<T>)vector.getClass();
                  Constructor<T> c = clazz.getConstructor(Integer.TYPE);
                  T copy = c.newInstance(new Object[] { vector.length() });
                  return copy;
              } catch (Exception e) {
                  throw new IllegalArgumentException("Cannot instantiate a vector"
                      + " of type " + vector.getClass(), e);
              }
          }
      }
docs: Creates a {@code Vector} instance of the same type and length of the
  provided vector.
  
  @param vector a vector whose type and length should be used when creating
  a new vector with the same properties
  
  @return a vector with the same type and length as the provided vector
  
  @throw IllegalArgumentException if <ul><li>the class of the provided
  vector does not have a constructor that takes in an {@code int} to
  specify the length <li>the class of the provided vector cannot be
  instantiated</ul>