Question about streamer -
RyDeR` - 28.07.2010
Hi,
I created an object streamer (in c++) (which worked good) a while ago, I worked with array sizes but I know that's not a good idea..
I only could stream 700.000 objects because the size of the array was only 700.000. (If I higher the array size, it got gave an error. Also a high array size is not good).
But now my question is:
what is the technique of streamer unlimited objects?
I looked trough the source of xStreamer and Incognito's streamer but I can't understand it :/
Really anyone can explain me, if need with some codes how to do it without 'array' sizes and just streamer as much as i want?
I appreciate all help.
(Note: I'm using SDK plugin for my plugins)
Regards
Re: Question about streamer -
Balon - 28.07.2010
for example
http://en.wikipedia.org/wiki/Vector_(C++)
There are more different implementations of dynamic arrays out there.
Re: Question about streamer -
RyDeR` - 28.07.2010
Thanks man.
Can you give some examples / usages of this if you got time and if you want of course?
Regards
EDIT: Can I also ask which (maybe easier) other ways exist?
Re: Question about streamer -
Remis - 29.07.2010
Quote:
Originally Posted by RyDeR`
(in c++)
|
You mean C, not C++. If you want to program in C++, put the arrays you know from C aside and begin programming in C++ - using vectors and other containers. (like Balon said).
http://www.parashift.com/c++-faq-lite/containers.html
It returns the error, because you are saving the objects on the stack, which has a limited size.
Begin storing them in the free store, which is only limited by the size of the RAM.
(The vector is saving his objects on the free store. You can also use new and delete - dynamic memory. The containers are using them.)
It is even more simpler if you would take use of the boost library. They have also solutions.
Edit: Examples
Vectors:
http://cplusplus.com/reference/stl/vector/
You add elements with push_back
http://cplusplus.com/reference/stl/vector/push_back/
There are examples
Dynamic Memory:
http://cplusplus.com/doc/tutorial/dynamic/
Boost library containers:
http://www.boost.org/doc/libs/1_43_0...htm#Containers
Re: Question about streamer -
RyDeR` - 30.07.2010
Alright thanks. Dynamic Memory is alright.
But a last problem.. I can't une multi dimensional array then.. :/
Like [value][value].
Regards
Re : Question about streamer -
scott1 - 30.07.2010
Ryder, where are you from belgium?
Re: Question about streamer -
Kar - 30.07.2010
RyDeR`
High-roller
Join Date: Feb 2009
Location: Belgium
Posts: 1,686
Re: Question about streamer -
RyDeR` - 30.07.2010
Yes I'm from Belgium.
____
Now someone please has an answer for my question?
Dynamic Memory works perfect with 1D array.
I also need an example with 2D arrays like [value][value]
Regards
Re: Question about streamer -
Remis - 30.07.2010
Create a 1D dynamic array first and then allocate for each member a new 1D dynamic array in a loop, so you have an array in an array. Remember to free the allocated memory right, like they did in the example.
http://www.cplusplus.com/forum/articles/7459/
"Pointer based multi-dimensional arrays"
You will find many topics in ****** about this because this is a very common question.
Re: Question about streamer -
kc - 30.07.2010
If you want to do what I think you need multi-dimensional arrays for the "proper C++ way", look into structs / classes.
Re: Question about streamer -
Romanius - 31.07.2010
Example for Vector
PHP код:
#include <vector>
using namespace std;
vector<int> ff;
int main()
{
for(int i; i < 500; i++)
{
ff.push_back(i);
}
for(int i; i < ff.size(); i++)
{
printf("%d", ff[i]);
}
system("PAUSE");
}