Author: Gian-Carlo Pascutto
Date: 00:55:52 06/06/05
Go up one level in this thread
On June 05, 2005 at 07:53:28, James Swafford wrote: >On June 04, 2005 at 19:10:03, Dieter Buerssner wrote: > >>On June 04, 2005 at 15:41:43, James Swafford wrote: >> >>>On June 03, 2005 at 17:29:32, Dieter Buerssner wrote: >> >>>>Are VLAs in C++? Java? >>> >>>In the java.util library there is a 'Vector' type. You simply add >>>objects to your Vector using the addElement( ) method. It takes >>>care of the rest for you. >>> >>>Conversely, you can remove elements using removeElement( ). >>> >>>There is also an ArrayList type that is (I think) about the same >>>thing. >> >>Thanks for your answer. Wouldn't using Vector imply the overhead of dynamic >>memory allocation and garbage collection (Nobody would care in an outer loop - >>but is it efficient inside an "inner loop" of a chess engine)? As Gerd just >>pointed out, VLAs in C are really cheap. Typically just an adjustment of the >>stack pointer. >> > >Yes, you're right of course. Convenience with a price! :) The price is pretty extreme - even with a modern JVM there is about a 300% performance penalty for using ArrayLists over arrays. (This is my experience with writing out algorithms both ways) -- GCP
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.