POV-Ray : Newsgroups : povray.off-topic : C++ questions : Re: C++ questions Server Time
7 Sep 2024 09:20:55 EDT (-0400)
  Re: C++ questions  
From: Slime
Date: 27 Sep 2008 18:39:51
Message: <48deb637@news.povray.org>
> Is there a "set" type laying around somewhere? The thing I'm processing 
> *is* notionally a set, not an ordered collection.

std::set, I believe. Internally it uses a binary tree so it can quickly 
search for things. This means that whatever type you use it on has to work 
with the < operator; it uses < to know how to order the tree. (This is 
relevant because it means you have to define the < operator if you want to 
use it with your own class.)

You can google "std set" for documentation. This works for most or all STL 
types. The useful member function here is find( value ), which returns an 
iterator to the element with the given value, or returns yourset.end() 
otherwise. (Oh, insert() is useful too.)

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.