home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / modules / libfont / src / wfList.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.1 KB  |  86 lines

  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19.  
  20. // wfList.h
  21. // A doubly linked list manager
  22. //
  23. // Created by dp Suresh <dp@netscape.com>
  24.  
  25. #ifndef __WF_LIST__
  26. #define __WF_LIST__
  27.  
  28. struct wfListElement;
  29. struct wfListElement {
  30.   void *item;
  31.   struct wfListElement *next;
  32.   struct wfListElement *prev;
  33. };
  34.  
  35. class wfList;
  36.  
  37. typedef void (*WF_FREE_FUNC)(wfList *object, void *item);
  38.  
  39. class wfList
  40. {
  41. public:
  42.   struct wfListElement *head;
  43.   struct wfListElement *tail;
  44.   WF_FREE_FUNC freeItemFunc;
  45.  
  46.   typedef enum {
  47.     WF_FALSE = 0,
  48.     WF_TRUE,
  49.     SUCCESS,
  50.     GENERIC_ERROR,
  51.     NOT_FOUND,
  52.     NO_MEMORY
  53. #if defined(XP_OS2)
  54.     /* insure that we know the size of this enum (4 bytes!) */
  55.     , ERROR_CODE_MAX = 70000 
  56. #endif
  57.   } ERROR_CODE;
  58.   typedef ERROR_CODE (*IteratorFunction) (void *);
  59.  
  60. public:
  61.   // Constructor
  62.   wfList(WF_FREE_FUNC freeFunc);
  63.  
  64.   // Destructor
  65.   ~wfList();
  66.  
  67.   // Private methods
  68. private:
  69.   struct wfListElement *find (void *item);
  70.   ERROR_CODE listAdd (struct wfListElement *ele);
  71.   ERROR_CODE listRemove (struct wfListElement *ele);
  72.   void listDeleteItem (void *item);
  73.  
  74.   // Public Methods
  75. public:
  76.   ERROR_CODE add (void *item);
  77.   ERROR_CODE remove (void *item);
  78.   ERROR_CODE removeAll(void);
  79.   ERROR_CODE isExist(void *item);
  80.   ERROR_CODE isEmpty(void);
  81.   int count(void);
  82.   ERROR_CODE iterate(IteratorFunction fn);
  83. };
  84.  
  85. #endif /* __WF_LIST__ */
  86.