What is the difference between an array, a tuple and a vector?

What is the difference between an array, a tuple and a vector?

POSIWID: The Purpose Of A System Is What It Does Shirt $21.68

UFOs Are A Psyop Shirt $21.68

POSIWID: The Purpose Of A System Is What It Does Shirt $21.68

  1. 1 month ago
    Anonymous

    Can't you do your own research homosexual?

    • 1 month ago
      Anonymous

      only faschist nazi conspiracy theorists makes their own research

  2. 1 month ago
    Anonymous

    just use a vector, forget about the first two

  3. 1 month ago
    Anonymous

    Vector is a sequential container to store elements and not index based. Array stores a fixed-size sequential collection of elements of the same type and it is index based. Vector is dynamic in nature so, size increases with insertion of elements. As array is fixed size, once initialized can't be resized.
    The structure of the tuple needs to stay the same (a string followed by a number), whereas the array can have any combination of the two types specified (this can be extended to as many types as is required).

    • 1 month ago
      Anonymous

      >As array is fixed size
      *laughs in VLA*

    • 1 month ago
      Anonymous

      > Vector is a sequential container to store elements and not index based.
      How do you retrieve elements from a vector then?

      • 1 month ago
        Anonymous

        no-one knows?
        huh. go figure.

      • 1 month ago
        Anonymous

        With an iterator.

        • 1 month ago
          Anonymous

          So to access the middle element in a million-sized vector you need to iterate over 500,000 elements?
          That seems like an incredibly inefficient data structure.

          • 1 month ago
            Anonymous

            Linked lists be like

          • 1 month ago
            Anonymous

            linked lists have their usecases, storing half a million elements that are independent of each other isn't one of them

            So vectors are literally just linked lists?

          • 1 month ago
            Anonymous

            linked lists have their usecases, storing half a million elements that are independent of each other isn't one of them

    • 1 month ago
      Anonymous

      I was hopelessly lost until this respectable gentleman explained this concept to me Itadakimasu or whatever the chink thank you is

    • 1 month ago
      Anonymous

      thanks chatgpt

    • 1 month ago
      Anonymous

      >Vector is a sequential container to store elements and not index based.
      So it's a linkedlist.

  4. 1 month ago
    Anonymous

    They are the same thing, applied to different scenarios

  5. 1 month ago
    Anonymous

    There is some difference in how languages use these terms but typically...

    An array is a contiguous region of memory that stores a fixed number of objects that are all of the same type.

    A tuple is kinda like an anonymous struct, with anonymous fields accessed by index. Every index has its own associated type.

    A vector is like an array but it has some extra bookkeeping that allows it to grow and shrink in size.

  6. 1 month ago
    Anonymous

    can modify content and can modify size: vector
    can modify content but can not modify size: array
    can not modify content and can not modify size: tuple

  7. 1 month ago
    Anonymous

    >ArrayList works similarly to std::vector
    who thought this was a good idea?

    • 1 month ago
      Anonymous

      You have to consider that it was made a long time ago. Names hadn't been so firmly established. Today list has a strong connotation of linked list but that was not true back then. Also vectors hadn't yet conclusively won over linked lists, which is why java offers multiple implementations of the List interface.

      You can see some other relics like this in c++ too. std::map is a tree based map, because hash maps hadn't won yet.

      • 1 month ago
        Anonymous

        Oh right I forgot, java even has a vector class named Vector. Unlike ArrayList, it is thread safe. I guess because back then it wasn't really known whether people would want thread safety by default or not.

  8. 1 month ago
    Anonymous

    a tuple is a contiguous sequence of elements of different types
    an array is a specialized tuple where all elements are of the same type
    a vector is a specialized array that is aligned to SIMD lanes
    a c++ vector is moronic nonsense, Black folk tongue my anus

  9. 1 month ago
    Anonymous

    An array is just a continuous block of memory that is N*type in bytes large, a vector is an array that automatically reallocates memory when the current array is filled
    A tuple is a struct of various data types

  10. 1 month ago
    Anonymous

    You posted a picture of a list, a tuple and a set.

  11. 1 month ago
    Anonymous

    array is a static length array
    tuple is an immutable array
    vector is a dynamic array

  12. 1 month ago
    Anonymous

    Nothing. It's all a fricking scam.

  13. 1 month ago
    Anonymous

    array: fixed size
    tuple: fixed size
    vector: array with realloc when it gets full

  14. 1 month ago
    Anonymous

    in C you use d = [] which is array where you can put values in and then use d[0] to use that value

    in python [] works same, you also have {} in which you can store keys and values of keys d = {key:value} you can also have more valies for keys like

    d = {key:{you, homosexual}}

    this way you can do d[key][1] this makes your program use homosexual value

  15. 1 month ago
    Anonymous

    yes let me google it for you

  16. 1 month ago
    Anonymous

    Arrays hold homogenous values in one fixed list. Tuples only hold two values in a small list. Vectors are arrays of variable lengths and can be resized at any time.

Your email address will not be published. Required fields are marked *