POV-Ray : Newsgroups : povray.off-topic : C++ questions : Re: C++ questions Server Time
7 Sep 2024 09:24:26 EDT (-0400)
  Re: C++ questions  
From: Orchid XP v8
Date: 28 Sep 2008 04:41:36
Message: <48df4340$1@news.povray.org>
Slime wrote:
>> 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.)

Heh. Exactly like Haskell's Data.Set ;-)

Question: What happens if your class doesn't have the comparison operator?

> 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.)

I'm more likely to be iterating the whole set and removing elements from 
it, but yeah. ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

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