[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Heirarchical Newsgroup list display

Posted on 2000-04-28
14
Medium Priority
?
158 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 400 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

650 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