HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_SparseArray.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 library (C++)
7  *
8  * COMMENTS: Mantains a sparse array of values.
9  *
10  */
11 
12 #ifndef __UT_SparseArray_h__
13 #define __UT_SparseArray_h__
14 
15 #include "UT_ValArray.h"
16 #include "UT_SmallObject.h"
17 
18 template <typename T>
20 public:
23 
24  void append(int index, T data);
25  void removeIndex(int index);
26 
27  void clear();
28 
29  // These operators find the index specified. If the index doesn't exist
30  // (i.e. hasn't been defined yet), a null value is returned.
31  T operator()(unsigned int i);
32  const T operator()(unsigned int i) const;
33 
34  // Find an index in the array, returns -1 if the entry doesn't exist.
35  int find(int index) const;
36 
37  // Returns the number of indices stored in the sparse array.
38  int entries() const { return (int)myArray.entries(); }
39 
40  // This method will not look up based on the array index, but rather on
41  // the actual array which stores the sparse entries.
42  T getRawEntry(int raw_index, int &index);
43 
44 private:
45  class SparseEntry : public UT_SmallObject<SparseEntry>
46  {
47  public:
48  SparseEntry(int i, T d) { myIndex = i; myData = d; }
49 
50  int myIndex;
51  T myData;
52  };
53 
54 
56 };
57 
58 #include "UT_SparseArrayImpl.h"
59 
60 #endif
int entries() const
T getRawEntry(int raw_index, int &index)
png_uint_32 i
Definition: png.h:2877
int find(int index) const
GLboolean * data
Definition: glcorearb.h:130
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:453
T operator()(unsigned int i)
GLuint index
Definition: glcorearb.h:785
void removeIndex(int index)
void append(int index, T data)