Class Vector

java.lang.Object
tema1.Vector

public class Vector extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    Vector(int... aelem)
    Constructor for Vector accepting an array of elements example: Vector myVector = new Vector(1,2,3,4,5,6); example2: Vector myVector = new Vector(1,2,3,4);
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(Vector tmp)
    Computes the sum of 2 vectors merging the second one in the first one example: Vector myVector = new Vector(1,2,3,4,5,6); Vector myVector2 = new Vector(10,12,13); myVector.add(myVector2) result: myVector now holds: 11,14,16,4,5,6 If the second vector has more elements then the first one, missing elements are merged EXCEPT IT DOESNT JUST DONT ADD A SMALLER VECTOR TO A BIGGER ONE OR UR CODE GONNA EXPLODE Ok it doesnt explode anymore, just ignores whatever is afterwards
    void
    Prints all elements to console
    int[]
    Returns all elements as an array
    void
    multiply(int x)
    Multiplies all elements in Vector with x example: myVector.multiply(5)
    int[]
    Returns an array of unique values in the vector

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Vector

      public Vector(int... aelem)
      Constructor for Vector accepting an array of elements example: Vector myVector = new Vector(1,2,3,4,5,6); example2: Vector myVector = new Vector(1,2,3,4);
      Parameters:
      aelem -
  • Method Details

    • display

      public void display()
      Prints all elements to console
    • getAll

      public int[] getAll()
      Returns all elements as an array
    • multiply

      public void multiply(int x)
      Multiplies all elements in Vector with x example: myVector.multiply(5)
      Parameters:
      x -
    • add

      public void add(Vector tmp)
      Computes the sum of 2 vectors merging the second one in the first one example: Vector myVector = new Vector(1,2,3,4,5,6); Vector myVector2 = new Vector(10,12,13); myVector.add(myVector2) result: myVector now holds: 11,14,16,4,5,6 If the second vector has more elements then the first one, missing elements are merged EXCEPT IT DOESNT JUST DONT ADD A SMALLER VECTOR TO A BIGGER ONE OR UR CODE GONNA EXPLODE Ok it doesnt explode anymore, just ignores whatever is afterwards
      Parameters:
      x -
    • unique

      public int[] unique()
      Returns an array of unique values in the vector