VTK  9.7.1
vtkVoidArray.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
12 #ifndef vtkVoidArray_h
13 #define vtkVoidArray_h
14 
15 #include "vtkCommonCoreModule.h" // For export macro
16 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_7_0
17 #include "vtkObject.h"
18 
19 VTK_ABI_NAMESPACE_BEGIN
20 class VTK_DEPRECATED_IN_9_7_0("No longer needed") VTKCOMMONCORE_EXPORT vtkVoidArray
21  : public vtkObject
22 {
23 public:
27  static vtkVoidArray* New();
28  static vtkVoidArray* ExtendedNew();
29 
30  vtkTypeMacro(vtkVoidArray, vtkObject);
31  void PrintSelf(ostream& os, vtkIndent indent) override;
32 
37  vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
38 
42  void Initialize();
43 
47  int GetDataType() const { return VTK_VOID; }
48 
52  int GetDataTypeSize() { return sizeof(void*); }
53 
58  {
59  this->Allocate(number);
60  this->NumberOfPointers = number;
61  }
62 
66  vtkIdType GetNumberOfPointers() { return this->NumberOfPointers; }
67 
71  void* GetVoidPointer(vtkIdType id) { return this->Array[id]; }
72 
76  void SetVoidPointer(vtkIdType id, void* ptr) { this->Array[id] = ptr; }
77 
82  void InsertVoidPointer(vtkIdType i, void* ptr);
83 
88  vtkIdType InsertNextVoidPointer(void* tuple);
89 
94  void Reset() { this->NumberOfPointers = 0; }
95 
99  void Squeeze() { this->ResizeAndExtend(this->NumberOfPointers); }
100 
105  void** GetPointer(vtkIdType id) { return this->Array + id; }
106 
112  void** WritePointer(vtkIdType id, vtkIdType number);
113 
117  void DeepCopy(vtkVoidArray* va);
118 
119 protected:
120  vtkVoidArray();
121  ~vtkVoidArray() override;
122 
125  void** Array; // pointer to data
126 
127  void** ResizeAndExtend(vtkIdType sz); // function to resize data
128 
129 private:
130  vtkVoidArray(const vtkVoidArray&) = delete;
131  void operator=(const vtkVoidArray&) = delete;
132 };
133 
134 VTK_ABI_NAMESPACE_END
135 #endif
vtkIdType GetNumberOfPointers()
Get the number of void* pointers held in the array.
Definition: vtkVoidArray.h:66
void * GetVoidPointer(vtkIdType id)
Get the void* pointer at the ith location.
Definition: vtkVoidArray.h:71
dynamic, self-adjusting array of void* pointers
Definition: vtkVoidArray.h:20
abstract base class for most VTK objects
Definition: vtkObject.h:52
#define VTK_VOID
Definition: vtkType.h:32
void SetVoidPointer(vtkIdType id, void *ptr)
Set the void* pointer value at the ith location in the array.
Definition: vtkVoidArray.h:76
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int GetDataType() const
Return the type of data.
Definition: vtkVoidArray.h:47
void Squeeze()
Resize the array to just fit the inserted memory.
Definition: vtkVoidArray.h:99
void ** GetPointer(vtkIdType id)
Get the address of a particular data index.
Definition: vtkVoidArray.h:105
void Reset()
Reuse already allocated data; make the container look like it is empty.
Definition: vtkVoidArray.h:94
int vtkIdType
Definition: vtkType.h:363
int GetDataTypeSize()
Return the size of the data contained in the array.
Definition: vtkVoidArray.h:52
vtkIdType NumberOfPointers
Definition: vtkVoidArray.h:123
int vtkTypeBool
Definition: vtkABI.h:64
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkIdType Size
Definition: vtkVoidArray.h:124
void ** Array
Definition: vtkVoidArray.h:125
void SetNumberOfPointers(vtkIdType number)
Set the number of void* pointers held in the array.
Definition: vtkVoidArray.h:57
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
#define VTK_DEPRECATED_IN_9_7_0(reason)