Don,
I can see your point... You *have* to store your data in an array because
you would like to render a PointArray. If you are frequently appending a
single point however you are right in saying that performance will be an
issue. One solution (read - hack) might be to periodically allocate space
for a large number of points and make the "unused" ones coincident (x,y,z)
with another real point (or place them outside the FOV). When you need to
append a new point you modify the x,y,z, of one of your points in the
"unused" pool.
You can decide how big the unused pool is and only reallocate the array when
the unused pool is empty.
You could get around this if the PointArray ignored nulls...
You should also take a look at the new 1.2 GeometryArray support for "by
reference" geometry. By allocating a large array and prepending elements
(your unused pool has to be at the front) and modifying the initial index
(setInitialCoordIndex) you can back your data towards element zero of the
array.
You definitely don't want to set a new array for coordinates each time you
append a point in 1.1.x as the array is copied internally as well!
Sincerely,
Daniel Selman
[EMAIL PROTECTED]
http://www.tornadolabs.com
> -----Original Message-----
> From: Discussion list for Java 3D API
> [mailto:[EMAIL PROTECTED]]On Behalf Of Jeremy Buchmann
> Sent: 22 January 2000 21:24
> To: [EMAIL PROTECTED]
> Subject: Re: [JAVA3D] appending arrays
>
>
> The Casteels wrote:
> >
> > I'd love to here everyone's opinion on the following, positive or
> > negative.
> >
> > I'm looking for a faster way to append arrays. Up to this point I'm
> > creating a new array every time I need to append, giving it a length of
> > n+1 then copying the data from my previous array into the new one and
> > filling the last space with the new data.
>
> IMHO, you should look for a better data structure than an array...maybe
> a linked list, or a stack/queue, etc. There are some books out there
> that describe the implementation of common data structures in Java, and
> there are lots of resources on java.sun.com.
>
> ==================================================================
> =========
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff JAVA3D-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".