Question about streamer
#1

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
Reply
#2

for example http://en.wikipedia.org/wiki/Vector_(C++)

There are more different implementations of dynamic arrays out there.
Reply
#3

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?
Reply
#4

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
Reply
#5

Alright thanks. Dynamic Memory is alright.
But a last problem.. I can't une multi dimensional array then.. :/
Like [value][value].

Regards
Reply
#6

Ryder, where are you from belgium?
Reply
#7

RyDeR`
High-roller




Join Date: Feb 2009
Location: Belgium
Posts: 1,686
Reply
#8

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
Reply
#9

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.
Reply
#10

If you want to do what I think you need multi-dimensional arrays for the "proper C++ way", look into structs / classes.
Reply
#11

Example for Vector

PHP код:
#include <vector>
using namespace std;
vector<intff;
int main()
{
    for(
int i500i++)
    {
        
ff.push_back(i);
    }
    for(
int iff.size(); i++)
    {
        
printf("%d"ff[i]);
    }
    
system("PAUSE");

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)