Fastream Technologies wrote:
> How about us to make a list of pointers in onlist and then remove?

Yes, I'd just override DoListNode, something like (untested):

  TMyCache = class(TCacheTree)
  private
    FDeleteList: TList;
    FCondition: string;
  protected
    procedure DoListNode(Node: TAvlTreeNode; var Cancel: Boolean); override;
  public
    destructor Destroy; override;
    procedure RemoveSomeStuff(const ACondition: String);
  end;


implementation


{ TMyCache }

type
  TMyData = record
    SomeStr : string;
  end;
  PMyData = ^TMyData;

procedure TMyCache.RemoveSomeStuff(const ACondition: String);
var
    I: Integer;
begin
    if not Assigned(FDeleteList) then
        FDeleteList := TList.Create;
    try
        FCondition := ACondition;
        ListTree;
        for I := 0 to FDeleteList.Count -1 do
            Remove(FDeleteList[I]);
    finally
        FDeleteList.Clear;
        FCondition := '';
    end;
end;

destructor TMyCache.Destroy;
begin
    FDeleteList.Free;
    inherited Destroy;
end;

procedure TMyCache.DoListNode(Node: TAvlTreeNode; var Cancel: Boolean);
begin
    if (Node <> nil) and (FCondition <> '') then
    begin
        if (PMyData(TCacheNode(Node).Data)^.SomeStr = FCondition) then
            FDeleteList.Add(Node);
    end
    else
      inherited;
end;





> Best Regards,
> 
> SZ
> On Sun, Dec 4, 2011 at 15:24, Fastream Technologies
> <ga...@fastream.com>wrote: 
> 
>> Arno,
>> 
>> The deletions occur once in a day/week or so, when the end admin user
>> clicks a button in GUI. It is not a part of every second cache
>> operation. What is the easiest/safest way to delete by iteration?
>> 
>> a. Implement a new TCacheTree with IPv6 AVLPointerTree?
>> b. A very slow workaround for the current class (speed is NOT an
>> issue). Best Regards,
>> 
>> SZ
>> On Sun, Dec 4, 2011 at 14:31, Arno Garrels <arno.garr...@gmx.de>
>> wrote: 
>> 
>>> Fastream Technologies wrote:
>>>> Ok but how do I delete with respect to a data->property??
>>> 
>>> One needs one linked tree for each search key, if you
>>> have to iterate over a tree in order to find something a list
>>> would likely be faster. But if can live with slow deletions
>>> maybe you can use TIcsAvlPointerTree rather than TAvlTree to write
>>> a new TCacheTree.
>>> 
>>>> We use
>>>> regex and string comparison for this! If you can help me with it, I
>>>> will appreciate. We can be sponsors for this feature. I think we
>>>> can live with OnList way but really need to be able to delete with
>>>> respect to data...
>>> 
>>> Sounds like plenty of keys, I'm not sure whether this would be
>>> faster with trees.
>>> 
>>> --
>>> Arno Garrels
>>> 
>>> 
>>> 
>>> --
>>> To unsubscribe or change your settings for TWSocket mailing list
>>> please goto
>>> http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket Visit our
>>> website at http://www.overbyte.be 
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to