Article View: news.software.readers
Article #50545Re: Threading algorithm
From: Douglas Cook
Date: Tue, 10 Aug 1999 00:00
Date: Tue, 10 Aug 1999 00:00
56 lines
2854 bytes
2854 bytes
You really need to use a hash table (also known as Maps or Dictionaries,
although there are minor variations between these) of some sort. They take
a key (in this case, the messageID) and in approximately linear time
(assuming you know beforehand how many items will be in the hash table) tell
whether the key is in the hash table. This is what my reader does:
root = value indicating that a child added at this point is not threaded;
while(there are more articles to read){
get article;
defaultAttachmentPoint = root;
references = article's references;
while((haven't found an attachmentPoint yet) && (references!="")){
reference = the last messageID in references;
references = references with its last messageID chopped off;
if(an article matching reference is in hash table){
defaultAttachmentPoint = the article pointed to by hash table;
found an attachmentPoint = true;
}
}
add article to tree view as child of defaultAttachmentPoint;
add article's messageID to hash table, and have it hash to its position in
tree;
}
And as far as the NNTP specification says and what every newsreader I know
of does, the content of the Subject line should have nothing to do with
whether it is considered a thread, but by default a news reader should make
the subject of the response be "Re:" followed by the original subject,
unless the original subject already has a "Re:". Check out RFC 977 if in
doubt.
Matthias Jordan wrote in message <37964124$0$217@nntp.ruhr.de>...
>Hi, Curt!
>
>>> moment it works really great so I decided to implement threading. I
>>> hacked a quick-and-dirty algorithm together but it has complexity
>>It would really help if you told us what the algorithm did.
>
>
>It sorts newsgroup articles by thread. In this particular case by use
>of the References header line. My current algorithm works like this:
>
>For every new article to insert into a newsgroup do this: If the new
>article has a References line, see whether there is the original
>article the new article refers to. If so, insert the new article
>behind the original one.
>
>Bye!
>Matthias
>
>
>
Technical Details
Message-ID:
<7oqk8d$j663@bbs2.pnl.gov>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<3796119b$0$216@nntp.ruhr.de> <19990721144534.708$be@newsreader.com> <37964124$0$217@nntp.ruhr.de>Show Full Headers
Complete Article Headers
Message-ID: <7oqk8d$j663@bbs2.pnl.gov> Subject: Re: Threading algorithm Date: Tue, 10 Aug 1999 00:00:00 +0000 From: "Douglas Cook" <cookd@cs.byu.edu> References: <3796119b$0$216@nntp.ruhr.de> <19990721144534.708$be@newsreader.com> <37964124$0$217@nntp.ruhr.de> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 511282501 Organization: Pacific Northwest National Lab X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3612.1700 Newsgroups: news.software.readers