Containers I'd like to see in std.containers

Johan Granberg lijat.meREM at OVEgmail.com
Sun Jun 6 11:48:27 PDT 2010


Philippe Sigaud wrote:

> On Mon, May 31, 2010 at 01:56, Andrei Alexandrescu <
> SeeWebsiteForEmail at erdani.org> wrote:
> 
>> On 05/30/2010 04:53 PM, Philippe Sigaud wrote:
>>
>>> There are some simple containers I'd like to see in std.containers:
>>>
>>> - a priority queue
>>> - a heap
>>>
>>
>> What's the difference between the two?
>>
> 
> Looking at some old code of mine, not much. Once you have a BinaryHeap, a
> PriorityQueue!(Payload,Priority) is just a BinaryHeap!(Tuple!(Payload,
> Priority))
> with a sorter acting on the tuple's second field and front() (or whatever
> it's called for containers) returning the first field.
> And, of course, nice creating functions.
> 
> So, heap is the basis, priority queue is just a nice wrapper. But I want
> nice wrappers! They are easy to code, and gives joe phobos what he wants.
> 
> 
> 
>>
>>  - a stack, a queue
>>>
>>
>> These are adaptors over other containers, I agree they should be in.
>>
> 
> Yes, an adaptor with a default implementation. Do you consider built-in
> arrays (not slices) to be containers?
> 
> 
> 
>>
>>  - a set
>>>
>>
>> Yah, though I want std.container to focus on implementation, not policy.
>>
> 
> Please, a set, please, a set!
> I mean, where would you put it otherwise?
> 
> 
> 
> Philippe

I also think a set would be highly usefull, and when defining it pleas don't
let the set operations (union,intersection,maybe complement) be defined. I
recently was writing some c++ code and got a nasty preformance hit from not
finding a fast set union operation.



More information about the Digitalmars-d mailing list