Array and Vector


 
Thread Tools Search this Thread
Top Forums Programming Array and Vector
# 8  
Old 11-14-2011
That's a very bizzare way to make a vector, unless you wanted an array of whatever * instead of an array of whatever...
# 9  
Old 11-15-2011
I am not sure as to what part of an array of pointers to struct type dont you get...its vectorized as each can be located anywhere in memory and not restricted to being sequential and have memory allocated throgh malloc calls.
# 10  
Old 11-15-2011
Quote:
Originally Posted by shamrock
I am not sure as to what part of an array of pointers to struct type dont you get...
I get it. I just don't understand what makes you think it's anything like a vector.
Quote:
its vectorized as each can be located anywhere in memory
C++ vectors are stored contiguously in memory, and allocated together, not individually. You may be thinking of sparse memory, like a C++ map<>?

Except this is a poor way to do sparse memory, too. You'd do that with a list of some sort, so you don't even store NULL pointers for empty elements.

What you've got could be used to build a hash table, perhaps.
# 11  
Old 11-15-2011
Quote:
Originally Posted by Corona688
I get it. I just don't understand what makes you think it's anything like a vector.
It is a vector in the simplest of sense...direction and magnitude.
Quote:
Originally Posted by Corona688
C++ vectors are stored contiguously in memory, and allocated together, not individually. You may be thinking of sparse memory, like a C++ map<>?
No i wasnt thinking of sparse memory but more on the lines of distributed memory...whose allocation may not be sequential but spread over pages that are currently in the processes address space without interleaving nulls.
Quote:
Originally Posted by Corona688
Except this is a poor way to do sparse memory, too. You'd do that with a list of some sort, so you don't even store NULL pointers for empty elements.

What you've got could be used to build a hash table, perhaps.
This type of data structure has quite a few applications with hash table being one of them...others include scatter gather I/O and storing variable length strings like the lines of a file for sorting later...and if your doubt persists lookup the manpages of the readv and writev system calls.
# 12  
Old 11-15-2011
Quote:
Originally Posted by shamrock
It is a vector in the simplest of sense...direction and magnitude.
Pretty sure the user was talking about C++ vectors, not the physics kind, not the writev kind.
# 13  
Old 11-15-2011
Quote:
Originally Posted by Corona688
Pretty sure the user was talking about C++ vectors, not the physics kind, not the writev kind.
That could very well be so as i said before...leave it upto the op to decide.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Vector normalisation

In AWK For 3 individual vectors of the form: -2.772 -9.341 -2.857 -5.140 -6.597 -1.823 -2.730 -5.615 1.159 I would like to write a script that parses line by line to (i) normalise, (ii) divide by the norm for *each* vector. I.e. sqrt(-2.772^2 + -9.341^2 + -2.857^2)=10.154 ... (4 Replies)
Discussion started by: chrisjorg
4 Replies

2. Programming

vector c++

hello guys. i'm new to c++. i've problem using two dimensional vector. i've a project of making conway's game of life. this is the code that i have made so far. my problem is how can i give a two dimensional vector through main. glider.vec1 = vec; is not correct way to give a two... (2 Replies)
Discussion started by: nishrestha
2 Replies

3. Programming

sort a vector

Hi all, I have a vector,the type of the element within it is list<int>,and i wanna sort this vector.So i implemented a function as a predicate for sort(the STL algorithm).Problem came when i missed the bold part in my code,g++ generated lots of error messages.And after i added the bold... (4 Replies)
Discussion started by: homeboy
4 Replies

4. Programming

Multidimensional array of strings with vector.

I've been struggling with this for quite some time. I decided I should get some help with this. Nothing is working. I'm getting a segmentation fault or out of bounds error when I try to load the entries in the for loop.I'm really frustrated. :mad: Compiling isn't the problem. It's crapping out on... (5 Replies)
Discussion started by: sepoto
5 Replies

5. Programming

C++ Map using a Vector as a Value Type?

I modified some code I found on Wikipedia concerning maps to see if it would work before applying it to a project I'm working on that has a similar idea. What I would want is for a user to be able to enter sentences and then be able to distinguish how many times a the person entered a word in a... (4 Replies)
Discussion started by: kcgb20
4 Replies

6. Programming

c++ mutidimentional arrays using vector

Hi! I need to make dynamic multidimensional arrays using the vector class. I found in this page How to dynamically create a two dimensional array? - Microsoft: Visual C++ FAQ - Tek-Tips the way to do it in 2D, and now i'm trying to expand it to 3D but i don't understand how is the operator working,... (1 Reply)
Discussion started by: carl.alv
1 Replies

7. Programming

multidimensional array using c++ vector

Hi! I need to make dynamic multidimensional arrays using the vector class. I found in this page How to dynamically create a two dimensional array? - Microsoft: Visual C++ FAQ - Tek-Tips the way to do it in 2D, and now i'm trying to expand it to 3D but i don't understand how is the operator working,... (0 Replies)
Discussion started by: carl.alv
0 Replies

8. Programming

Vector Traversing

Hi i have the following structure struct S { char Mod_num; char val; char chr_nm_cd; } I am reading a 2GB file and inserting into the structure and writing into a vector. I feel like only vector will be a right option. I tried with multimap but it is memory intensive and hence i... (1 Reply)
Discussion started by: dhanamurthy
1 Replies

9. Programming

Linker error when using vector's

using SUN C++ I have a problem when I do a push_back on a vector. The linker gives me a undefined symbol error on __cxa_end_catch. Any ideas, is there a library to include? Thanks Chris (1 Reply)
Discussion started by: CDurkin
1 Replies

10. Programming

Saving a vector to a file

Another C++ question, please do notify me if this forum is C-only! :) I'm having a vector... vector<Person> x; ... with a class I've defined (Person). I have several elements in this vector and I would like to save it to a file (binary (?)). And later on open up this file to retrieve... (1 Reply)
Discussion started by: J.P
1 Replies
Login or Register to Ask a Question