Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Anyone using STL?

Author: Jon Dart

Date: 09:31:38 07/26/02

Go up one level in this thread


On July 26, 2002 at 03:43:53, Russell Reagan wrote:

>I was curious if anyone was using STL in their engine, or if that is a bad idea.
>For example, I considered using an std::vector to store my legal moves in during
>the search. After thinking about this, I realized it probably wasn't a good idea
>since vector allocates memory dynamically when calling push_back() (if the
>vector is full).
>
>The question I have is whether or not using a vector in this case is a good or
>bad idea, or if it won't really affect performance.

Bad idea. Just use a fixed-size array on the stack (sized to the maximum number
of moves you ever expect - 256 is an ok number). You don't ever want to do
dynamic memory allocation in the search if you can avoid it. It is a big
performance hit.

More generally, I don't recommend STL because of the inconsistent
implementations that various compiler vendors have done.

Arasan has its own templatized typesafe vector class (which is used for stuff
that is not frequently updated). It doesn't use STL <vector> because of
portability problems and bugs in some implementations. (It does use <string> a
few places).

--Jon



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.