VTK  9.3.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 "vtkObject.h"
17 
18 VTK_ABI_NAMESPACE_BEGIN
19 class VTKCOMMONCORE_EXPORT vtkVoidArray : public vtkObject
20 {
21 public:
25  static vtkVoidArray* New();
26  static vtkVoidArray* ExtendedNew();
27 
28  vtkTypeMacro(vtkVoidArray, vtkObject);
29  void PrintSelf(ostream& os, vtkIndent indent) override;
30 
35  vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext = 1000);
36 
40  void Initialize();
41 
45  int GetDataType() const { return VTK_VOID; }
46 
50  int GetDataTypeSize() { return sizeof(void*); }
51 
56  {
57  this->Allocate(number);
58  this->NumberOfPointers = number;
59  }
60 
64  vtkIdType GetNumberOfPointers() { return this->NumberOfPointers; }
65 
69  void* GetVoidPointer(vtkIdType id) { return this->Array[id]; }
70 
74  void SetVoidPointer(vtkIdType id, void* ptr) { this->Array[id] = ptr; }
75 
80  void InsertVoidPointer(vtkIdType i, void* ptr);
81 
86  vtkIdType InsertNextVoidPointer(void* tuple);
87 
92  void Reset() { this->NumberOfPointers = 0; }
93 
97  void Squeeze() { this->ResizeAndExtend(this->NumberOfPointers); }
98 
103  void** GetPointer(vtkIdType id) { return this->Array + id; }
104 
110  void** WritePointer(vtkIdType id, vtkIdType number);
111 
115  void DeepCopy(vtkVoidArray* va);
116 
117 protected:
118  vtkVoidArray();
119  ~vtkVoidArray() override;
120 
123  void** Array; // pointer to data
124 
125  void** ResizeAndExtend(vtkIdType sz); // function to resize data
126 
127 private:
128  vtkVoidArray(const vtkVoidArray&) = delete;
129  void operator=(const vtkVoidArray&) = delete;
130 };
131 
132 VTK_ABI_NAMESPACE_END
133 #endif
vtkIdType GetNumberOfPointers()
Get the number of void* pointers held in the array.
Definition: vtkVoidArray.h:64
void * GetVoidPointer(vtkIdType id)
Get the void* pointer at the ith location.
Definition: vtkVoidArray.h:69
dynamic, self-adjusting array of void* pointers
Definition: vtkVoidArray.h:19
abstract base class for most VTK objects
Definition: vtkObject.h:51
#define VTK_VOID
Definition: vtkType.h:31
void SetVoidPointer(vtkIdType id, void *ptr)
Set the void* pointer value at the ith location in the array.
Definition: vtkVoidArray.h:74
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:45
void Squeeze()
Resize the array to just fit the inserted memory.
Definition: vtkVoidArray.h:97
void ** GetPointer(vtkIdType id)
Get the address of a particular data index.
Definition: vtkVoidArray.h:103
void Reset()
Reuse already allocated data; make the container look like it is empty.
Definition: vtkVoidArray.h:92
int vtkIdType
Definition: vtkType.h:315
int GetDataTypeSize()
Return the size of the data contained in the array.
Definition: vtkVoidArray.h:50
vtkIdType NumberOfPointers
Definition: vtkVoidArray.h:121
int vtkTypeBool
Definition: vtkABI.h:64
a simple class to control print indentation
Definition: vtkIndent.h:28
vtkIdType Size
Definition: vtkVoidArray.h:122
void ** Array
Definition: vtkVoidArray.h:123
void SetNumberOfPointers(vtkIdType number)
Set the number of void* pointers held in the array.
Definition: vtkVoidArray.h:55
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...