Class DSortedList

Inherits from:
DList
Declared in:
DSortedList.h

Class Hierarchy

    Object
      |
      +---DList
	    |
	    +---DSortedList

Class Description

The DSortedList class implements a number of methods for using a sorted double linked lists. This class maintains a sorted list. During inserting of objects this list is kept sorted. As a result a number of insert related methods of the parent class DList are disabled and return a warning.

Example:
#include <stdio.h>
#include "ofc/DSortedList.h"

int main(int argc, char *argv[])
{
  DSortedList *list = [DSortedList alloc];
  DText       *str;
  char        *names[] = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
  int          n;

  [list init :[DText class] :YES];  // Insert text in sorted list, ascending sorted

  for (n = 0; n < sizeof(names) / sizeof(names[0]); n++)  // Insert the day names, keep them sorted
  {
    DText *str = [DText new];

    [str set :names[n]];

    [list insert :str];                // Insert the string
  }

  str = [list join :','];              // Join the list for printing
  printf("Sorted day names:%s.\n", [str cstring]);
  [str free];

  [list free];                         // Cleanup

  return 0;
}
Last modified:
07-Aug-2008 (DSortedList.h)

Instance Variables

private BOOL _ascending
is the list sorted ascending ? (else descending)
private Class _class
the class of the objects

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0