dcollections 0.01 release

janderson askme at me.com
Wed May 7 20:54:31 PDT 2008


BCS wrote:
> Reply to Steven,
> 
>> "torhu" wrote
>>
>>> Steven Schveighoffer wrote:
>>>
>>>> I've been tinkering with a collection package that is a hybrid
>>>> between C++, Java, and Tango, utilizing the best D features (such as
>>>> slicing, foreach, etc.).
>>>>
>>> Interesting stuff.  Any plans for adding sorting?
>>>
>> I wasn't planning on it...
>>
>> I think sorting really only makes sense in cases where quick lookup is
>> possible.  The implementations I support are:
>>
>> RBTree -> already sorted
>> Hash -> can't be sorted
>> Link -> don't have quick lookup.
>> Array -> possible to sort using the built-in array sort:
>> ArrayList!(int) x([5,4,3,2,1]);
>>
>> x.asArray.sort;
>>
>> Basically, for ArrayList, any possible sort routines that are written
>> for builtin arrays can be applied.
>>
>> For unsortable implementations, they can be 'sorted' by adding them to
>> a Tree implementation, which will sort on insertion.  Or if you like,
>> turned into an array, and sorted there.
>>
>> Is there another requirement I'm missing?
>>
>> -Steve
>>
> 
> One thing that might make this easier would be a collection of 
> collections type:
> 
> Many!(T, RBTree, Array) foo
> 
> foo would have the API for both RBTree and Array but adding/removing 
> to/from one would also do the same to the other. This might be more 
> useful with something like several RBTrees where each is sorted 
> differently.
> 

If I understand you correctly, it could also be useful if you want to 
iterate quickly though a list, and also find something quickly other 
times.  Particularly if you have a hash and a array put together.

-Joel


More information about the Digitalmars-d-announce mailing list