Vector Table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kittykat

    Vector Table

    Hey everyone,
    I know this is a stupid question, BUT, i have read both the c++ books i
    have at home, and have searched through several websites...but i still
    can't find the answer. The question is, is there such a thing called
    "Vector Table" that is already a function in C++?

    By function i mean, like array.

    I have written some code that would create the Vector Table, but i was
    just wondering if there was a simpler way?

    Thanx in advance.



  • Jonathan Turkanis

    #2
    Re: Vector Table


    "kittykat" <f_arikat@nospa m.hotmail.com> wrote:
    [color=blue]
    > Hey everyone,
    > I know this is a stupid question,[/color]

    I wouldn't call it stupid. Inscrutable, maybe.
    [color=blue]
    > BUT, i have read both the c++ books i
    > have at home,[/color]

    Which books? Maybe they're among the many horrible C++ books.
    [color=blue]
    > and have searched through several websites...but i still
    > can't find the answer. The question is, is there such a thing called
    > "Vector Table" that is already a function in C++?[/color]

    "Vector Table" is not a legal function name, since it contains a space character
    ;-)
    [color=blue]
    > By function i mean, like array.[/color]

    Here's where your question starts to get murky. "array" isn't a (standard
    library) function in C++. So "Vector Table" and "array" are similar ("like") in
    that neither is a function in C++.
    [color=blue]
    > I have written some code that would create the Vector Table, but i was
    > just wondering if there was a simpler way?[/color]

    I wouldn't be suprised. But you'll have to explain what your code does.
    [color=blue]
    > Thanx in advance.[/color]

    This is a dangerous practice -- you really should read what I've written before
    thanking me ;-)

    Jonathan


    Comment

    • kittykat

      #3
      Re: Vector Table

      :) i mean, is there a variable, like array, where you can write something
      like vecTable[12], and that would create a vecTable with 12 rows for
      example?

      Comment

      • adbarnet

        #4
        Re: Vector Table

        You can instantiate a std::vector and have it create space for the number of
        elements you specify:

        typedef std::vector<Typ e> vecTypes;
        vecTypes myTypeVector(12 );

        would create space for 12 'Types', and call the int default constructor for
        each one.

        You can also use resize on constructed vectors to make them the size you
        want.


        "kittykat" <f_arikat@nospa m.hotmail.com> wrote in message
        news:00b2f48322 c436dacc81aec4f dd31d56@localho st.talkaboutpro gramming.com...[color=blue]
        > :) i mean, is there a variable, like array, where you can write something
        > like vecTable[12], and that would create a vecTable with 12 rows for
        > example?
        >[/color]


        Comment

        • kittykat

          #5
          Re: Vector Table

          Do all the elements of a Vector Table? have to be of the same data type?
          for example, could it have rows with letters, and columns with integers?

          0 1 2 3 4 5 6
          A
          B
          C
          D

          Comment

          • news-east

            #6
            Re: Vector Table

            Don't know what you mean...

            Are you talking about indexing into your table with different types? - If
            so, then:

            typedef std::map<int, TableElementTyp e> rowData;
            typedef std::map<char, RowData> dataTable;

            would work:
            dataTable tbl;
            TableElementTyp e t = tbl['A'][2];

            and there are alternatives - but the important thing is the data-type of the
            elements themselves...

            "kittykat" <f_arikat@nospa m.hotmail.com> wrote in message
            news:7dbab6890c 631f1d8cf2079a4 a68f71a@localho st.talkaboutpro gramming.com...[color=blue]
            > Do all the elements of a Vector Table? have to be of the same data type?
            > for example, could it have rows with letters, and columns with integers?
            >
            > 0 1 2 3 4 5 6
            > A
            > B
            > C
            > D
            >
            >[/color]



            Posted Via Usenet.com Premium Usenet Newsgroup Services
            ----------------------------------------------------------
            ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
            ----------------------------------------------------------
            Best Usenet Service Providers 2025 ranked by Newsgroup Access Newsservers, Usenet Search, Features & Free Trial. Add VPN for privacy.

            Comment

            • Jon Bell

              #7
              Re: Vector Table

              In article <7dbab6890c631f 1d8cf2079a4a68f 71a@localhost.t alkaboutprogram ming.com>,
              kittykat <f_arikat@nospa m.hotmail.com> wrote:[color=blue]
              >Do all the elements of a Vector Table? have to be of the same data type?[/color]

              Can you give a specific example of a Vector Table, with some example data?
              I've *never* seen the term "Vector Table" before your first posting about
              them, either in a C++ context or an any other context. I just did a
              Google search on "vector table" (with the quotes, to keep the words
              together) and got some references to hardware interrupts in
              microprocessors . Somehow I doubt that's what you're asking about. :-)

              --
              Jon Bell <jtbellm4h@pres by.edu> Presbyterian College
              Dept. of Physics and Computer Science Clinton, South Carolina USA

              Comment

              • Howard

                #8
                Re: Vector Table


                "kittykat" <f_arikat@nospa m.hotmail.com> wrote in message
                news:7dbab6890c 631f1d8cf2079a4 a68f71a@localho st.talkaboutpro gramming.com...[color=blue]
                > Do all the elements of a Vector Table? have to be of the same data type?
                > for example, could it have rows with letters, and columns with integers?
                >
                > 0 1 2 3 4 5 6
                > A
                > B
                > C
                > D
                >[/color]

                You're not making much sense here. What's a "Vector Table"? What you're
                showing above is a display of "headers" for columns and rows of some sort of
                data table. But there is no data displayed in any of the "cells". Your
                questions ask about two unrelated things.

                "Do all elements have to be the same type?" Well, that depends upon what
                you mean by "type". You can store strings in the cells, and those strings
                can be numbers or letters or puncuation or whatever. Alternatively, you can
                have a vector of vectors (or an array of arrays, if you want to do things
                the hard way and not make use of the std classes). Then, each vector can
                hold a given type of data (such as integer, string, char, double). Or, you
                can store a base class object in every cell, and let polymorphism handle the
                details of what's in the cell and how to display it.

                But none of that has anything to do with "rows" or "columns". That's all up
                to how you output the data (to a screen, for example). You merely write out
                the data however you want. Just because you have an array X[4][5] doesn't
                mean there are four "rows" and five "columns", or vice-versa. You're free
                to display those however you want.

                And how you display the "headers" for those rows or columns is also
                completely up to you. You don't even have to store that information
                anywhere. When outputting the data, you can simply write the "column" index
                across the top of the page, and when writing each row out, you can simply
                add the "row" index to the value for the letter 'A' to generate the other
                letters.

                The important thing is really what you're trying to display as data in the
                actual cells, which you haven't said.

                -Howard






                Comment

                Working...