473,472 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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.

Jul 22 '05 #1
7 8349

"kittykat" <f_******@nospam.hotmail.com> wrote:
Hey everyone,
I know this is a stupid question,
I wouldn't call it stupid. Inscrutable, maybe.
BUT, i have read both the c++ books i
have at home,
Which books? Maybe they're among the many horrible C++ books.
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++?
"Vector Table" is not a legal function name, since it contains a space character
;-)
By function i mean, like array.
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++.
I have written some code that would create the Vector Table, but i was
just wondering if there was a simpler way?
I wouldn't be suprised. But you'll have to explain what your code does.
Thanx in advance.


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

Jonathan
Jul 22 '05 #2
:) 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?

Jul 22 '05 #3
You can instantiate a std::vector and have it create space for the number of
elements you specify:

typedef std::vector<Type> 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_******@nospam.hotmail.com> wrote in message
news:00******************************@localhost.ta lkaboutprogramming.com...
:) 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?

Jul 22 '05 #4
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

Jul 22 '05 #5
Don't know what you mean...

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

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

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

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

"kittykat" <f_******@nospam.hotmail.com> wrote in message
news:7d******************************@localhost.ta lkaboutprogramming.com...
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


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Jul 22 '05 #6
In article <7d******************************@localhost.talkab outprogramming.com>,
kittykat <f_******@nospam.hotmail.com> wrote:
Do all the elements of a Vector Table? have to be of the same data type?


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 <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
Jul 22 '05 #7

"kittykat" <f_******@nospam.hotmail.com> wrote in message
news:7d******************************@localhost.ta lkaboutprogramming.com...
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


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


Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Stefan Burger | last post by:
Those of you who are in need for drawing vector lines might be interested in the following code. DrawLine( x1, y1, x2, y2, color ) draws a vector line from any Point x1,y1 to any Point x2,y2 in...
12
by: BCC | last post by:
If I create a vector of vectors of double: std::vector< std::vector<double> > table1; Are my vectors of doubles uninitialized? Do I have to loop through table1 and initialize each vector of...
14
by: Alex Vinokur | last post by:
Here is some function that detects if a vector contains only different elements bool vector_contains_only_different_elements (const vector<int>& v) { for (int i = 0; i < v.size(); i++) { if...
16
by: Kitty | last post by:
Hi, everyone. Given a vector<int>, what is the fastest way to find out whether there is a repeated element in it? The result is just "true" or "false". Thanks. Kitty
34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
5
by: ma740988 | last post by:
Hopefully I'm not asking too much here, nontheless consider the test source: #include <vector> #include <utility> using std::vector; using std::pair; #define INVALID_ID -1
4
by: fatgirl.brown | last post by:
Hi all, I am attempting to initialize a vector of a vector in a constructor with some clean-looking syntax and am not sure of how to go about this. For instance: double weight; vector<...
5
by: streamkid | last post by:
i have a class table, which has a vector of records(-db). i 'm trying to remove an element, but it doesn't seem to work.. i read this http://www.cppreference.com/cppvector/erase.html] and that's...
16
by: xyz | last post by:
I have to run the simulation of a trace file around (7gb contains 116million entries)... presently i am using vector iterators to check the conditions in my program..... it is taking 2 days to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.