HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
UT_ThingList.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_ThingList.h ( UT Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __UT_ThingList__
12 #define __UT_ThingList__
13 
14 #include "UT_API.h"
15 #include <stdio.h>
16 #include "UT_Defines.h"
17 #include "UT_Thing.h"
18 #include "UT_Hash.h"
19 #include "UT_SmallObject.h"
20 
21 #include <SYS/SYS_Deprecated.h>
22 
24 
30 {
31 public:
34  UT_ThingEntry *next;
35 };
36 
37 class SYS_DEPRECATED_REPLACE(16.0, "std::list") UT_API UT_ThingList {
38 public:
39  UT_ThingList();
40  ~UT_ThingList();
41 
42  // if 'ordered' is true, you must define UT_Hash::strcmp properly,
43  // to return -1, 0 and 1 based on <, = or >; not just 0 or 1.
44  int insertEntry(const UT_Hash &name, const UT_Thing & value,
45  bool ordered = false);
46  int findEntry(const UT_Hash &name, UT_Thing *valuep,
47  bool ordered = false) const;
48  int findEntry(const UT_Hash &name, UT_Thing *valuep,
49  const UT_Hash **namep, bool ordered = false) const;
50  UT_Thing &getEntry(const UT_Hash &name, int *created = 0,
51  bool ordered = false);
52  int deleteEntry(const UT_Hash &name,
53  bool ordered = false);
54 
55  const UT_Hash & getHashReference(const UT_Hash &name, int *created = 0,
56  bool ordered = false);
57 
58  int count() const;
59  int traverse(int (*function)(UT_Thing &, const UT_Hash &, void *),
60  void *data) const;
61 
62  unsigned entries(void) const;
63  unsigned empty(void) const; // Return true if empty
64 
65  int64 getMemoryUsage(bool inclusive) const;
66 
67 
68  // These methods are called by UT_HashTable when rebuilding the hash table.
70  // This function removes a UT_ThingEntry from the list and returns it
71  // so it can be modified and re-inserted to this list or another.
73  bool ordered);
74  // Inserts an entry into this list.
75  void insertThingEntry(UT_ThingEntry &thing_entry,
76  bool ordered);
77 
79  {
80  public:
82  : myCurrEntry(0) { }
84  { *this = src; }
85  ~traverser() { }
86 
87  UT_Thing &thing() const { return myCurrEntry->data; }
88  UT_Hash *hash() const { return myCurrEntry->name; }
89 
90  int operator==(const traverser &cmp) const
91  { return (myCurrEntry == cmp.myCurrEntry); }
92  int operator!=(const traverser &cmp) const
93  { return !(*this == cmp); }
94 
96  {
97  myCurrEntry = myCurrEntry->next;
98  return *this;
99  }
100 
102  {
103  myCurrEntry = src.myCurrEntry;
104  return *this;
105  }
106 
107  private:
109  : myCurrEntry(sym) { }
110 
111  UT_ThingEntry *myCurrEntry;
112 
113  friend class UT_ThingList;
114  };
115 
116  traverser begin() const { return traverser(symbols); }
117  traverser end() const { return traverser(); }
118 
119 private:
120  UT_ThingEntry *findOrCreate(const UT_Hash &name, int *created,
121  bool ordered);
122  UT_ThingEntry *symbols;
123 };
124 
126 
127 #endif
void insertThingEntry(UT_ThingEntry &thing_entry, bool ordered)
int traverse(int(*function)(UT_Thing &, const UT_Hash &, void *), void *data) const
int insertEntry(const UT_Hash &name, const UT_Thing &value, bool ordered=false)
#define SYS_DEPRECATED(__V__)
#define UT_SMALLOBJECT_PAGESIZE_DEFAULT
int findEntry(const UT_Hash &name, UT_Thing *valuep, bool ordered=false) const
UT_Thing & getEntry(const UT_Hash &name, int *created=0, bool ordered=false)
traverser begin() const
Definition: UT_ThingList.h:116
UT_Hash * hash() const
Definition: UT_ThingList.h:88
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
UT_ThingEntry * next
Definition: UT_ThingList.h:34
unsigned empty(void) const
#define UT_API
Definition: UT_API.h:12
int64 getMemoryUsage(bool inclusive) const
Definition: UT_ThingList.h:25
int operator!=(const traverser &cmp) const
Definition: UT_ThingList.h:92
traverser(const traverser &src)
Definition: UT_ThingList.h:83
UT_ThingEntry * removeFirstThingEntry()
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
long long int64
Definition: SYS_Types.h:106
#define UT_SMALLOBJECT_THREADSAFE_DEFAULT
UT_Thing & thing() const
Definition: UT_ThingList.h:87
UT_Hash * name
Definition: UT_ThingList.h:33
traverser end() const
Definition: UT_ThingList.h:117
GLboolean * data
Definition: glcorearb.h:130
GLuint const GLchar * name
Definition: glcorearb.h:785
unsigned entries(void) const
int operator==(const traverser &cmp) const
Definition: UT_ThingList.h:90
int cmp(T a, T b)
Definition: ImathFun.h:119
#define UT_SMALLOBJECT_CLEANPAGES_DEFAULT
GLsizei const GLfloat * value
Definition: glcorearb.h:823
int count() const
traverser & operator++()
Definition: UT_ThingList.h:95
const UT_Hash & getHashReference(const UT_Hash &name, int *created=0, bool ordered=false)
const traverser & operator=(const traverser &src)
Definition: UT_ThingList.h:101
UT_Thing data
Definition: UT_ThingList.h:32
GLenum src
Definition: glcorearb.h:1792
int deleteEntry(const UT_Hash &name, bool ordered=false)