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_Array.h"
16 #include "UT_NonCopyable.h"
17 #include "UT_SmallObject.h"
18 
19 template <typename T>
21 {
22 public:
25 
27 
28  void append(int index, T data);
29  void removeIndex(int index);
30 
31  void clear();
32 
33  // These operators find the index specified. If the index doesn't exist
34  // (i.e. hasn't been defined yet), a null value is returned.
35  T operator()(unsigned int i);
36  const T operator()(unsigned int i) const;
37 
38  // Find an index in the array, returns -1 if the entry doesn't exist.
39  int find(int index) const;
40 
41  // Returns the number of indices stored in the sparse array.
42  int entries() const { return (int)myArray.entries(); }
43 
44  // This method will not look up based on the array index, but rather on
45  // the actual array which stores the sparse entries.
46  T getRawEntry(int raw_index, int &index);
47 
48 private:
49  class SparseEntry : public UT_SmallObject<SparseEntry>
50  {
51  public:
52  SparseEntry(int i, T d) { myIndex = i; myData = d; }
53 
54  int myIndex;
55  T myData;
56  };
57 
58 
60 };
61 
62 #include "UT_SparseArrayImpl.h"
63 
64 #endif
int entries() const
T getRawEntry(int raw_index, int &index)
int find(int index) const
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
exint entries() const
Alias of size(). size() is preferred.
Definition: UT_Array.h:648
T operator()(unsigned int i)
GLuint index
Definition: glcorearb.h:786
void removeIndex(int index)
void append(int index, T data)
Definition: format.h:895