HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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_Thing.h"
17 #include "UT_Hash.h"
18 #include "UT_SmallObject.h"
19 
20 #include <SYS/SYS_Deprecated.h>
21 
23 
29 {
30 public:
33  UT_ThingEntry *next;
34 };
35 
36 class SYS_DEPRECATED_REPLACE(16.0, "std::list") UT_API UT_ThingList {
37 public:
38  UT_ThingList();
39  ~UT_ThingList();
40 
41  // if 'ordered' is true, you must define UT_Hash::strcmp properly,
42  // to return -1, 0 and 1 based on <, = or >; not just 0 or 1.
43  int insertEntry(const UT_Hash &name, const UT_Thing & value,
44  bool ordered = false);
45  int findEntry(const UT_Hash &name, UT_Thing *valuep,
46  bool ordered = false) const;
47  int findEntry(const UT_Hash &name, UT_Thing *valuep,
48  const UT_Hash **namep, bool ordered = false) const;
49  UT_Thing &getEntry(const UT_Hash &name, int *created = 0,
50  bool ordered = false);
51  int deleteEntry(const UT_Hash &name,
52  bool ordered = false);
53 
54  const UT_Hash & getHashReference(const UT_Hash &name, int *created = 0,
55  bool ordered = false);
56 
57  int count() const;
58  int traverse(int (*function)(UT_Thing &, const UT_Hash &, void *),
59  void *data) const;
60 
61  unsigned entries() const;
62  unsigned empty() const; // Return true if empty
63 
64  int64 getMemoryUsage(bool inclusive) const;
65 
66 
67  // These methods are called by UT_HashTable when rebuilding the hash table.
69  // This function removes a UT_ThingEntry from the list and returns it
70  // so it can be modified and re-inserted to this list or another.
72  bool ordered);
73  // Inserts an entry into this list.
74  void insertThingEntry(UT_ThingEntry &thing_entry,
75  bool ordered);
76 
78  {
79  public:
81  : myCurrEntry(0) { }
83  { *this = src; }
84  ~traverser() { }
85 
86  UT_Thing &thing() const { return myCurrEntry->data; }
87  UT_Hash *hash() const { return myCurrEntry->name; }
88 
89  int operator==(const traverser &cmp) const
90  { return (myCurrEntry == cmp.myCurrEntry); }
91  int operator!=(const traverser &cmp) const
92  { return !(*this == cmp); }
93 
95  {
96  myCurrEntry = myCurrEntry->next;
97  return *this;
98  }
99 
101  {
102  myCurrEntry = src.myCurrEntry;
103  return *this;
104  }
105 
106  private:
108  : myCurrEntry(sym) { }
109 
110  UT_ThingEntry *myCurrEntry;
111 
112  friend class UT_ThingList;
113  };
114 
115  traverser begin() const { return traverser(symbols); }
116  traverser end() const { return traverser(); }
117 
118 private:
119  UT_ThingEntry *findOrCreate(const UT_Hash &name, int *created,
120  bool ordered);
121  UT_ThingEntry *symbols;
122 };
123 
125 
126 #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
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:629
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:115
unsigned entries() const
UT_Hash * hash() const
Definition: UT_ThingList.h:87
#define SYS_DEPRECATED_PUSH_DISABLE()
#define SYS_DEPRECATED_POP_DISABLE()
UT_ThingEntry * next
Definition: UT_ThingList.h:33
#define UT_API
Definition: UT_API.h:14
int64 getMemoryUsage(bool inclusive) const
GLuint const GLchar * name
Definition: glcorearb.h:785
Definition: UT_ThingList.h:24
GLenum src
Definition: glcorearb.h:1792
int operator!=(const traverser &cmp) const
Definition: UT_ThingList.h:91
traverser(const traverser &src)
Definition: UT_ThingList.h:82
UT_ThingEntry * removeFirstThingEntry()
#define SYS_DEPRECATED_REPLACE(__V__, __R__)
unsigned empty() const
#define UT_SMALLOBJECT_THREADSAFE_DEFAULT
UT_Thing & thing() const
Definition: UT_ThingList.h:86
UT_Hash * name
Definition: UT_ThingList.h:32
traverser end() const
Definition: UT_ThingList.h:116
long long int64
Definition: SYS_Types.h:116
int operator==(const traverser &cmp) const
Definition: UT_ThingList.h:89
int cmp(T a, T b)
Definition: ImathFun.h:119
GLboolean * data
Definition: glcorearb.h:130
#define UT_SMALLOBJECT_CLEANPAGES_DEFAULT
int count() const
traverser & operator++()
Definition: UT_ThingList.h:94
GLsizei const GLfloat * value
Definition: glcorearb.h:823
const UT_Hash & getHashReference(const UT_Hash &name, int *created=0, bool ordered=false)
const traverser & operator=(const traverser &src)
Definition: UT_ThingList.h:100
UT_Thing data
Definition: UT_ThingList.h:31
int deleteEntry(const UT_Hash &name, bool ordered=false)