Solved

Heirarchical Newsgroup list display

Posted on 2000-04-28
14
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

689 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