Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Getting Started with Vectors

Sumit Rawal answered on May 23, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers

  • how vector graphics store
  • vector3.up
  • support vector machine example
  • create vectors of vectors c++
  • how to create vector inside vecotor in c++
  • Creating a Vector#
  • install vector
  • vector commands

  • Getting Started with Vectors

    0

    Introduction

    Creating a Vector

    Initializing an Empty Vector

    Accessing an Element

    Appending an Element

    Prepending an Element

    Vector Concatenation

    Introduction

    Like Lists, Vectors are another immutable collection of sequence type. They differ in the fact that Lists are linear while Vectors are indexed. What this means is that if you want to access a central element in a List, the compiler has to start from the beginning and linearly progress through the List until it finds the element you are trying to access. However, when you want to access a central element in a Vector, the compiler can directly go to that index and access the element in constant time.

    While Lists should be used when you only plan to manipulate the head element (first element), Vectors provide efficient access when you want to manipulate elements beyond the head.

    Creating a Vector

    Vectors can be created using the Vector keyword followed by (). 

    Popularity 1/10 Helpfulness 1/10 Language scala
    Source: Grepper
    Tags: scala
    Link to this answer
    Share Copy Link
    Contributed on May 23 2023
    Sumit Rawal
    0 Answers  Avg Quality 2/10


    X

    Continue with Google

    By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
    X
    Grepper Account Login Required

    Oops, You will need to install Grepper and log-in to perform this action.