BrainDump
  Home arrow BrainDump arrow Page 2 - Working with NSort and RSS.NET
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Working with NSort and RSS.NET
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2007-08-28

    Table of Contents:
  • Working with NSort and RSS.NET
  • Using NSort
  • 4.9 Creating RSS Feeds with RSS.NET
  • Creating an RSS feed

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Working with NSort and RSS.NET - Using NSort


    (Page 2 of 4 )

    The NSort Library provides 15 different sort algorithms:

    1. Bidirectional Bubble Sort
    2. Bubble Sort
    3. Combo Sort 11
    4. Double Storage Merge Sort
    5. Fast Quick Sorter
    6. Heap Sort
    7. In Place Merge Sort
    8. Insertion Sort
    9. Odd/Even Transport Sort
    10. Quick Sort
    11. Quick Sort with Bubble Sort
    12. Selection Sort
    13. Shaker Sort
    14. Shear Sort
    15. Shell Sort

    These sorters vary in best-and worst-case sort times and in memory usage. Unfortunately, determining the optimal sorter isn’t always easy. It’s not just a matter of choosing one with the “best”worst-case sort time and the least amount of memory utilization. Performance depends on the size of your list and on how much of the data is already sorted. One sorter may perform very well under one set of conditions and poorly under a different set. For this reason, Quick Sort with Bubble Sort often makes a good default sorter. This sorter reverts to a Bubble Sort for small sets of data, which is more efficient than a Quick Sort. For large sets, it uses the Quick Sort algorithm first, then applies the Bubble Sort on the smaller fragments.

    Using the sorters is straightforward. Decide which sorter you wish to use and instantiate it. Here’s an example that requests a Bubble Sort:

      private ISorter sorter = new BubbleSorter();

    Next, create the list of items to be sorted. TheSort()method takes anIListrepresenting an enumerable collection. For example, to sort a set of random numbers:

      Random rnd = new Random();
      int[] list = new int[1000];

      for(int i = 0;i<list.Length;++i)
      {

        list[i] = rnd.Next();
      }

      ArrayList mylist=new ArrayList(list);
      sorter.Sort(mylist);

    The default constructor for each of the sorters instantiates theComparableComparer andDefaultSwapclasses. These handle all value types and any class or struct implementingIComparable.

    You can also customize the comparer and swapper by implementingIComparerandISwapclasses. All the sorters have an additional constructor:

      public xxx(IComparer comparer, ISwap swapper)

    This constructor can be used to specify your own compare and swap algorithms. This is a very useful feature of these classes, allowing you to sort not just value types, but also classes and structs that do not implementIComparable. Conversely, you can implementIComparableon your own classes to support custom comparisons.

    Many of the sorters in NSort are ported from sorting demonstration code in Java, available at http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html.

    For more information on sorting, refer to John Robbins’s MSDN article “Make Your Apps Fly with the New Enterprise Performance Tool,”available at http:// msdn.microsoft.com/msdnmag/issues/04/12/EnterprisePerformance/default.aspx. You can also find an overview of sorting on Wikipedia at http://en.wikipedia.org/wiki/ Sort_algorithms.

    Getting Support

    NSort is supported via the tool’s Code Project article at http://www.codeproject.com/ csharp/cssorters.asp and at http://www.marcclifton.com.

    Problems or questions can be posted in the comments section for the Code Project article or in the forum at Marc Clifton’s web site.

     

    NSort Library in a Nutshell

    NSort is a useful collection of sorting algorithms that enables you to select a sorter suitable
    for your requirements. The algorithms are very flexible, as the core comparer supports
    classes implementing IComparable and can be overridden for classes that don’t support IComparable. You can also override the default swap algorithm to handle custom
    swapping of objects and values.

    —Marc Clifton, cocreator of NSort

    More BrainDump Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Windows Developer Power Tools," published...
     

    Buy this book now. This article is excerpted from chapter four of the book Windows Developer Power Tools, written by James Avery and Jim Holmes (O'Reilly; ISBN: 0596527543). Check it out today at your favorite bookstore. Buy this book now.

    BRAINDUMP ARTICLES

    - Internet Explorer 8 Review
    - Nilpo`s Top Windows Add-Ons
    - Beginning Silverlight 2.0 Development using ...
    - Fixing Vista`s Troubles
    - Preparing Windows Images for Mass Deployment
    - The Trouble With Vista
    - Slipstreamed and Unattended Windows Installa...
    - Microsoft Office SharePoint Server
    - Microsoft Office SharePoint Designer
    - Microsoft Windows SharePoint Services 3.0
    - Microsoft Live Mesh Overview
    - XAML Brushes and Silverlight
    - Silverlight and XAML Basics
    - Immortal XP
    - XAML Basics





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT