[yunqa.de] Re: DIContainers

  • From: Delphi Inspiration <delphi@xxxxxxxx>
  • To: yunqa@xxxxxxxxxxxxx
  • Date: Fri, 14 Mar 2008 17:49:02 +0100

ColdBear wrote:

>I?m struggling to get to grips with how to create the 3 rd  layer ?Type? 
>structures. I get the basic concepts, but am lost when trying to take a 
>TDIVector and create a new structured type from it. At the moment I can?t get 
>past using TDIVector directly and only having untyped access. I would really 
>like to start creating structured containers, but could use a worked example 
>or two to put me on the right path. 
> 
>My first goal is to create a floating point equivalent of TDIIntegerVector 
>i.e. TDIExtendedVector or similar.

The attached archive contains an example project to show how you can do this 
fairly easily. The Float ItemHandler part is contained in a separate unit which 
automatically cleans up after itself. You can reuse this for all container 
types (TDIVector, TDITree, you name it).

The demo project contains simple examples about how to add floats to the vector 
as well as iterating, assigning, and sorting.

Looks like you are in fact looking for some classes like TDIExtendedVector, 
TDIDoubleVector, etc., no? ;-)

>Also, I?m trying to make use of TDInteger2Vector, but I don?t think it?s 
>designed for the purpose I want (again I would then create a new type for 
>this). Essentially I want to treat Number and Nunmber2 as a primary key. The  
>?ExistsNumberNumber2?   function lets me identify if the pair exist, but there 
>is no ?Index? to tell me where.  I suspect the TDInteger2Vector is meant to be 
>used with only one of the numbers used for sorting and locating ?

True. The problem with paired number items is that the number of functions 
grows exponentially with all possible options implemented. However, I have 
added the function to the code-base so it will be available with the next 
version.

For the time being, you can help yourself with the little workaround function 
as demonstrated in the attached archive.

Ralf 

Other related posts: