"Phango" container classes
BLS
nanali at nospam-wanadoo.fr
Tue Oct 2 01:44:56 PDT 2007
Bill Baxter schrieb:
> Bruce Adams wrote:
>> Bill Baxter Wrote:
>>
>>> I just decided to do a little experiment to see how hard it would be
>>> to make Tango's containers work with Phobos.
>>>
>>> Answer: less than an hour's work.
>>>
>>> Here's all it takes:
>>> - Copy tango/util/collections/* to phango/util/collections/*.
>>> - Copy tango/core/Exception.di to phango/core/Exception.d
>>> - Replace all instances of 'tango' with 'phango'.
>>> - Replace all instances of 'toUtf8' with 'toString'
>>> - Comment out the IReader,IWriter imports in LinkMap.d
>>> - Comment out all function prototypes in Exception.d.
>>> - Make TracedException a simple subclass of Exception in Exception.d.
>>> - Comment out anything else in Exception.d that gives compiler errors.
>>>
>>> Then voila! You have a set of container classes for Phobos.
>>>
>>> I did some rudimentary testing by copying all the unittests from the
>>> containers to one big containers.d test program. After changing
>>> Cout's to writefln's, all seems to work like a charm.
>>>
>>> So this is a possible option for anyone who would like a set of
>>> Java-esque container classes to use with Phobos. Certainly a heck of
>>> a lot easier than trying to port any implementation of C++ std::map
>>> to D. :-)
>>>
>>> --bb
>>
>> Good stuff. Have you posted the source anywhere?
>
> No I mostly wanted to point out that the Tango containers are 95%
> independent of the Tango-specific runtime features, and easy to port to
> Phobos. And I wanted to suggest the cool name "Phango, evil twin
> brother of Tangobos". :-) Maybe "Phandango" would be a better name,
> though.
>
Phandango is excellent reminds on a song from
PROCUL HARUM -
"A Brighter Shade Of Pale” :)
We skipped the light Phandango
Turned cartwheels 'cross the floor
I was feeling kind of seasick
But the crowd called out for more
Just kidding, Bjoern
>> I see tango uses Red-black trees in some places so in those its STL
>> equivalent or better anyway.
>
> Yes, the TreeSet and TreeMap should have same asymptotic performance
> characteristics as STL std::set and std::map.
>
>> I guess we will get all this stuff as
>> soon as the tango / phobos incompatability is resolved.
>
> That's what I'm thinking too. But I wanted to point out that anyone who
> is desperate for containers today can extract them from Tango with less
> than an hour's work of mostly mindless search and replace.
>
>> Out of
>> interest, if you just throw the all incompatibles out of tango what
>> kind of phango are we left with? Does it look like a worthwhile job?
>
> I suspect you'd still have most of it. Far easier than porting C++ code
> anyway. Maybe the threading stuff is too dependent on tango's Object to
> port easily. I'm not sure.
>
> --bb
More information about the Digitalmars-d
mailing list