home *** CD-ROM | disk | FTP | other *** search
/ IRIS Development Option 6.2 / IRIS_Development_Option_6.2_814-0478-001.iso / dist / motif_dev.idb / usr / include / Sgm / SgList.h.z / SgList.h
C/C++ Source or Header  |  1996-03-14  |  1KB  |  74 lines

  1. /* 
  2.  * File SgList.hh
  3.  * Written By: Ofer Ben-Shachar, January 1992
  4.  *
  5.  * Definition for the SgList Class
  6.  *
  7.  */
  8.  
  9.  
  10. #ifndef _SGLIST_H
  11. #define _SGLIST_H
  12.  
  13. enum IStatus { SUCCESS, FAILURE };
  14.  
  15. enum IBoolean { IFALSE, ITRUE };
  16.  
  17.  
  18. class SgListNode {
  19. public:
  20.   void * operator new(size_t size);
  21.   
  22.   void operator delete( void * obj );
  23.  
  24.   void *object;
  25.   SgListNode *prev;
  26.   SgListNode *next;
  27. };
  28.  
  29.  
  30. class SgList
  31. {
  32.    SgListNode *head;     
  33.    SgListNode *tail;
  34.    SgListNode *currentNode;
  35.    int count;
  36.  
  37.  public:
  38.   void * operator new(size_t size);
  39.   
  40.   void operator delete( void * obj );
  41.  
  42.   SgList();
  43.    ~SgList();
  44.  
  45.    // Iterating on the list
  46.    void InitIterate();
  47.    void *Next();
  48.    void *Prev();
  49.    
  50.  
  51.    // Location functions
  52.    IStatus LocateFront();
  53.    IStatus LocateEnd();
  54.    IStatus Locate(void *object);
  55.    int CurrentPosition();  // 1 is the first entry
  56.    IStatus LocatePosition(int i);   
  57.    
  58.    // List manipulating
  59.    IBoolean IsInList(void *object);
  60.    void *Retrieve();
  61.    void *First();
  62.    void *Last();
  63.    IStatus Insert(void *obj);
  64.    IStatus Append(void *obj);
  65.    IStatus Replace(void *obj); // replace current node with obj
  66.    void *Remove();   // removes the current node from the list and returns it
  67.    IStatus Delete(); // deletes the current node from the list.
  68.    void Clear();     // Clears the List DOES not free the objects.
  69.    IBoolean Empty()  {return ((head == 0) ? ITRUE : IFALSE);}
  70.    int Count()  {return count;}
  71. };   
  72.  
  73. #endif    // _SGLIST_H
  74.