Article View: news.software.readers
Article #232338My Visual C++/Visual Stuido newsReader.
From: Jeffâ–˛Relf
Date: Wed, 08 Apr 2009 21:10
Date: Wed, 08 Apr 2009 21:10
105 lines
5338 bytes
5338 bytes
You're an interesting fellow, Mr. Allen.
You don't like Visual C++ and you have no interest in newsReaders,
but here's a comparison routine ( using in a quickSort )
that I wrote to sort posts in a newsGroup.
It could be an alternate scoring system for slrn or Google Groups,
for example.
Some of the variable names have Unicode glyphs in them,
glyphs that xNews can't display; Google Groups displays them,
as will various Unix-like newsReaders ( Pan, kNode and slrn ).
For sorting, each post would have this information:
A. The catagory it's in, “ Top·0, Middle·1, Bottom·2 ”.
“ Top ” has replies to the user,
“ Bottom ” has posts the user made “ ― the rest are in “ Middle ”.
B. Information about the nym who made the post, to wit:
1. His count of unRead posts, “ cnt·unReads ”.
2. His xRank ( a 64 bit float ), based on who replied to him.
3. How long ago he last posted, “ DaysAgoLatest ”.
C. How old the post is, “ AgeDays ”.
D. A boolean, to know if the post was read or not, “ wasRead ”.
( “ nonWatched ” nyms are muffled, so that no more than
the 3 most-recent are marked as “ unRead ”.
No nym has more than 30 “ wasRead ” posts. )
From “ www.JeffRelf.F-M.FM/X.CPP ”, in Visual C++ 9:
[ “ www.JeffRelf.F-M.FM/X.ZIP ” has X.EXE, settings in X.TXT ]
// “ Case ” is the post that's being scored;
// “ Vs ” is the post Case is being compared against.
// Lower numbers ( e.g. larger negative numbers )
// come first, at the top of the list.
inline double Cmp( LsP Case, LsP Vs ) {
// There are 3 Catagories ( Cat ): “ Top·0, Middle·1, Bottom·2 ”.
// “ Top ” has replies to me, “ Bottom ” has posts I made;
// the rest are in “ Middle ”.
if ( Case->Cat != Vs->Cat )
// “ Case ” goes up the list ( e.g. has a larger negative number )
// when “ Vs ” has a higher “ Cat ”.
return Case->Cat - Vs->Cat ;
NymT & caseNym = * Case->Nym, & vsNym = * Vs->Nym ;
if ( Case->Cat == Cat_Mid && & caseNym != & vsNym ) {
// Both Case and Vs are in Cat_Mid and
// they don't have the same nym.
if ( !vsNym.cnt·unReads != !caseNym.cnt·unReads )
// Case goes up the list when
// caseNym has unReads and vsNym doesn't.
return !caseNym.cnt·unReads - !vsNym.cnt·unReads ;
if ( caseNym.xRank == vsNym.xRank )
// caseNym and vsNym have the same xRank.
// Case goes up the list when vsNym hasn't posted as recently.
// This groups posts by nym because
// no two nyms have the same xRank And the same DaysAgoLatest.
// DaysAgoLatest is a float with a one second resolution.
return caseNym.DaysAgoLatest - vsNym.DaysAgoLatest ;
// Case goes up when caseNym has a higher xRank.
return vsNym.xRank - caseNym.xRank ;
}
if ( Case->Cat == Cat_Bot )
// Case and Vs are in Cat_Bot ( i.e. they're posts I've made ).
// Sort by oldest first,
// so my most recent post is at the very bottom.
// Case goes up when it's older.
return Vs->AgeDays - Case->AgeDays ;
// Case and Vs either “ have the same nym and are in Cat_Mid ”
// or they're both in Cat_Top, possibly with differnt nyms.
if ( Case->wasRead != Vs->wasRead )
// Both posts are in Cat_Mid, with the same nym,
// because Cat_Top has no wasRead posts.
// Case goes up when it's unRead and Vs isn't.
return Case->wasRead - Vs->wasRead ;
// Sort by youngest first, Case goes up when Vs is older.
return Case->AgeDays - Vs->AgeDays ; }
// This “ Quick Sorts ” posts using Cmp() ( above ).
ByCatxRankNymVistdAge( LsA _B, LsA _E ) { if ( _E <= _B ) return;
LsA BB = _B - 1, EE = _E + 1 ; LsP Std = _B [ ( _E - _B ) / 2 ] ;
LOOP {
while ( Cmp( * ++ BB , Std ) < 0. );
while ( EE >= BB && Cmp( * -- EE , Std ) > 0. );
if ( EE <= BB ) break; LsP T = * BB ; * BB = * EE ; * EE = T ; }
ByCatxRankNymVistdAge ( _B, EE < _E ? EE : -- EE );
ByCatxRankNymVistdAge ( EE + 1, _E ); }
Technical Details
Message-ID:
<Jeff_Relf@Seattle.2009_Apr.8|2.10pm|I>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-sci.math.(840047).mbox.7z!not-for-mailReferences:
<odKdnSWap4Ogq0_UnZ2dnUVZ_rmdnZ2d@posted.docknet> <a9453b9d-3e31-41d0-8e69-d7f7a239a8a2@o11g2000yql.googlegroups.com> <OtadnR0nmqiVM0fUnZ2dnUVZ_s2dnZ2d@posted.docknet> <Jeff_Relf@Seattle.2009_Apr.6|7.59pm|A> <84c39f63-f2c2-47de-85c0-8332d9ffd4fd@b16g2000yqb.googlegroups.com> <Xns9BE78E7842224jamesdowallen@news.albasani.net>Show Full Headers
Complete Article Headers
Message-ID: <Jeff_Relf@Seattle.2009_Apr.8|2.10pm|I> Subject: My Visual C++/Visual Stuido newsReader. Date: Wed, 08 Apr 2009 21:10:16 +0000 From: Jeffâ–˛Relf <Jeff_Relf@Seattle.inValid> References: <odKdnSWap4Ogq0_UnZ2dnUVZ_rmdnZ2d@posted.docknet> <a9453b9d-3e31-41d0-8e69-d7f7a239a8a2@o11g2000yql.googlegroups.com> <OtadnR0nmqiVM0fUnZ2dnUVZ_s2dnZ2d@posted.docknet> <Jeff_Relf@Seattle.2009_Apr.6|7.59pm|A> <84c39f63-f2c2-47de-85c0-8332d9ffd4fd@b16g2000yqb.googlegroups.com> <Xns9BE78E7842224jamesdowallen@news.albasani.net> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-sci.math.(840047).mbox.7z!not-for-mail Newsgroups: news.software.readers,sci.math Lines: 103 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net AW9+Lo+8FMqrk4/IyzSqnglIBqm9cK+6D13ezK6lPnbVLmrXqP Cancel-Lock: sha1:YInaK3SxtPvZ4zIde2QA/n+yk6A= User-Agent: JeffRelf.F-M.FM/X.ZIP