Re: C++ vs Java "new" (no flame war please!)



mlw wrote:
> (snipped description of custom 'new' operator)

Is there a way to create 10 to 100 million objects in Java with a reasonable
system configuration?

Sure, given the same considerations of available heap that you would have in the C++ world.

Let's assume you want to create N objects where N is the largest number of such objects that would fit in available memory.

List <Foo> stuff = new ArrayList <Foo> (N);
for ( int x = 0; x < N; ++x )
{
stuff.add( new Foo( getAString() ) );
}
doSomethingWith( stuff );

If you don't need them all in memory at once, it's even easier:

for ( int x = 0; x < N; ++x )
{
Foo foo = new Foo( getAString() );
doSomethingWith( foo );
}

I posit the 'getAString()' method as where you'd obtain the equivalent of the 'char * string' in the C++ example. I assumed you'd use a different string for each instance of Foo.

-- Lew
.



Relevant Pages

  • Re: Forth Frustrations
    ... If you have a word that accepts a string then it's easy to get the ... we could do "FOO to tell the compiler to keep FOO ready, ... The address was HERE after the child was completed. ... lay down the two literals and then the execute, ...
    (comp.lang.forth)
  • Re: Forth Frustrations
    ... If you have a word that accepts a string then it's easy to get the ... we could do "FOO to tell the compiler to keep FOO ready, ... The address was HERE after the child was completed. ... lay down the two literals and then the execute, ...
    (comp.lang.forth)
  • Re: Forth Frustrations
    ... If you have a word that accepts a string then it's easy to get the ... we could do "FOO to tell the compiler to keep FOO ready, ... The address was HERE after the child was completed. ... lay down the two literals and then the execute, ...
    (comp.lang.forth)
  • Re: Forth Frustrations
    ... If you have a word that accepts a string then it's easy to get the ... we could do "FOO to tell the compiler to keep FOO ready, ... The address was HERE after the child was completed. ... lay down the two literals and then the execute, ...
    (comp.lang.forth)
  • Re: regexp non-greedy matching bug?
    ... pattern in question. ... >> non-greedy or minimal fashion... ... this pattern doesn't look for one or two instances of "foo" in ... It looks for a string that starts with "foo" and maybe has a ...
    (comp.lang.python)