Solved

Heirarchical Newsgroup list display

Posted on 2000-04-28
14
148 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now