Collections 1.0

Last week I have finally got some free time on my hands to do something I was planning for a long time now: create a new package that will only provide a number of collections. What this means is that I took DeHL and stripped out everything that was not collection related; remodeled the classes to rely on Generics.Collections and Generics.Defaults standard units; and finished all the documentation.

 

What remained is a pure collection orientated package called (very unimaginatively)  Collections.  If you ever used DeHL’s collections you will most certainly recognize the code. But, while stripping out the bloat I was forced to re move some things that relied on that bloat:

  • No more reliance on IType/TType. Collections now use IComparer and IEqualityComparer provided by Generics.Defaults.
  • All associative collections use TPair now.
  • Because IType was designed to provide cleanup for the enclosed values in the collections some reworking was necessary to make collections more Delphi-like. You still get the OwnsObjects, OwnsKeys and OwnsValues properties on the object variants.
  • No more Op.Cast<> support. This Enex operation relied on TConverter which relied on IType and so on and so forth. Instead use a Op.Select with a casting predicate.
  • Using NativeInt instead of NativeUInt in some places. This was a menace for a lot of people.

Note that Collections is not base-class or interface compatible with Generics.Collections. I could not make the proper compatibility because of interface support.
So what would you expect in the package:

  • Full inline documentation. All APIs are properly documented. If you find any typos or errors please fill a bug!
  • Test cases for mostly everything provided.
  • A wide range of collections (much more than just stack, queue, list and dictionary).
  • Enumerable extensions.
  • Easy extensibility.
  • Based on NativeInt instead of Integer. Ready at interface level for 64bit support.

Warning: This is a 1.0 release. There may still be some problems. If you find any please fill in a bug report. If you feel that you can help and implement something that is not included in the package feel free to contact me!

You May Also Like

About the Author: Alexandru Ciobanu

8 Comments

  1. Very nice. Do you have any plans to implement an Enex-style thread-communication queue like the new TThreadedQueue from XE?

    Also, wouldn’t it be possible to implement an Op.Cast that calls Op.Select internally, to make porting easier?

  2. @Mason Wheeler
    If anyone’s going to help me I want to add parallel extensions. I don’t have time to do it myself though….

    Implementing cast is a really big task. You need a lot of conversion code. BTW, internally Cast was a Select with a conversion anon procedure. But the big bulk of work is not left in DeHL.

    You can always define a function like:

    ConvertIntToStr(const AInt: Integer): string;
    begin
    Exit(IntToStr(AInt));
    end;

    and then call select like

    StrList := IntList.Op.Select(ConvertIntToStr);

  3. Very nice. I always wanted to use the DeHL for the collections and enex but it was to much bloat for me.
    Now if the package only would be compilable.
    I tried in Delphi XE ([DCC Fatal Error] Collections.Base.pas(5827): F2084 Internal Error: AV22223FF9-R00000000-0) and in Delphi 2010 ([DCC Error] Collections.Base.pas(6611): E2003 Undeclared Identifier: ‘EArgumentNilException’).

Leave a Reply to Tommi Prami Cancel reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.