[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

Heirarchical Newsgroup list display

I would like to be able to display in a treeview-like component a list of usenet newsgroups much like the listing in Netscape when you subscribe to the list of available groups. I can do this now but not efficiently or quickly.

Thanks
0
ldi
Asked:
ldi
  • 7
  • 6
1 Solution
 
LischkeCommented:
Ahem, and what is your question? Is it that you need a faster control to display the data or a faster algorithm to sort those many newsgroups or what else?

Ciao, Mike
0
 
ldiAuthor Commented:
I have an amazingly fast control i'm using so
Display isn't the issue. What I need is a good
method of sorting and storing the groupnames
in a datastructure for later display in the Treeview

Andif it could look like the one in Netscape that's be great.
0
 
LischkeCommented:
You are not accidently Mark L. Holmes? I'm asking because I'm going to answer just this question to him this weekend. The fast treeview is then my virtual treeview, correct :-))?

Ciao, Mike
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
ldiAuthor Commented:
Yup, It's me i took your advice and came to this site you reccommended
0
 
LischkeCommented:
Hi Mark,

I thought this stuff would be quite easy to solve, but the longer I thought the tougher became the problem :-) Your main problem is, I think, that you cannot do a binary search through the tree nodes, because you must have a fast possibility to find the middle node between two given nodes. In a doubly linked list there is only the way to keep a count of nodes between start and node (which must not necessarily be the list's start and/or end points) and iterate quickly by looping from sibling to sibling half this count. That is also the weak point in my solution. Perhaps there is a cleverer algorithm to do a string search but I don't know one currently.

Once you have a quick node search for a particular string you can do the following:

  for each string entry (SE) do
  begin
    // a SE is in the form aaa.bbb.ccc... etc. where aaa, bbb and ccc are substrings of SE
    Init a node pointer with the root of the treeview (the one not visible) to access the top level nodes.

    Extract first substring into S.
    while S <> '' do
    begin
      Do a binary search in the child nodes of the current node pointer for this sub string.

      This search should either return the found node or the last one just before where
      the node in question would be if it exists (this is just like the binary search in TStringList).

      If a node could be found then set the node pointer to this node.
      Otherwise add a sibling to the returned node, set its text to S and the node pointer to this new node.
      // You can make this more fail save by checking whether the returned node is less or above S.

      Extract next substring into S.
    end;
  end;

You can see here the algo is as such very simple, but should execute very fast. The lookup would be like:

function FindChildNodeFromString(Node: PVirtualNode; S: String; var Child: PVirtualNode): Boolean;

// Looks through the children of node and returns the node corresponding to S. If successful then
// the result is True otherwise False (in which case Child contains a node as nearest as possible to S).

var
  L, H, M: PVirtualNode;
  I, C: Integer;

begin
  Result := False;
  L := Node.FirstChild;
  H := Node.LastChild;
  while L.Index <= H.Index do
  begin
    I := (L.Index + H.Index) shr 1;
    // this is the only weak point here because we need a linear search for the node with index I
    M := L;
    Dec(I, L.Index);
    while I > 0 do
    begin
      M := M.NextSibling;
      Dec(I);
    end;

    C := CompareText(TextFromNode(M), S);
    if C < 0 then L := M.NextSibling
             else
    begin
      H := M.PreviousSibling;
      if C = 0 then
      begin
        Result := True;
        L := M;
      end;
    end;
  end;
  Child := L;
end;


This code is not tested but should work very fine.

Ciao, Mike
0
 
LischkeCommented:
Idi, how is it going?

Ciao, Mike
0
 
ldiAuthor Commented:
It's going just fine. I still haven't implemented your suggestion yet. :-(

How is the beta for the new tree component coming along? Any new progress?
0
 
ldiAuthor Commented:
Comment accepted as answer
0
 
LischkeCommented:
Hi Idi, thanks for the points, anyway. Well, VT is doing very fine. I hope to get it out soon. Docs still need to be written, as well as some minor features. Just today I implemented a sort feature which works with an application callback.

Read you

Ciao, Mike
0
 
ldiAuthor Commented:
Feel free to send me you latest version :-)
0
 
LischkeCommented:
Sorry, I'd currently prefer not to give out the latest version until I have made some other changes as well as some decisions about the licensing scheme.

Ciao, Mike
0
 
ldiAuthor Commented:
Alrighty then
0
 
markshifferCommented:
What are you using to get your newsgroup display?

The FastNet in Delphi is extremely slow, are there any alternatives?
0
 
ldiAuthor Commented:
Yes. You can use Winshoes or as it is now called Indy. www.nevrona.com/indy

I'm a member of the Indy "pit crew" so i'm biased :-)

Mark
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now