Solved

Heirarchical Newsgroup list display

Posted on 2000-04-28
14
151 Views
Last Modified: 2010-04-04
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
Comment
Question by:ldi
  • 7
  • 6
14 Comments
 
LVL 10

Expert Comment

by:Lischke
ID: 2759717
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
 

Author Comment

by:ldi
ID: 2759728
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
 
LVL 10

Expert Comment

by:Lischke
ID: 2759774
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:ldi
ID: 2759787
Yup, It's me i took your advice and came to this site you reccommended
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2762532
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
 
LVL 10

Accepted Solution

by:
Lischke earned 100 total points
ID: 2892309
Idi, how is it going?

Ciao, Mike
0
 

Author Comment

by:ldi
ID: 2892526
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
 

Author Comment

by:ldi
ID: 2892528
Comment accepted as answer
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2893357
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
 

Author Comment

by:ldi
ID: 2893550
Feel free to send me you latest version :-)
0
 
LVL 10

Expert Comment

by:Lischke
ID: 2895936
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
 

Author Comment

by:ldi
ID: 2895943
Alrighty then
0
 
LVL 3

Expert Comment

by:markshiffer
ID: 4517053
What are you using to get your newsgroup display?

The FastNet in Delphi is extremely slow, are there any alternatives?
0
 

Author Comment

by:ldi
ID: 4517703
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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question