VTK  9.4.20241121
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
18VTK_ABI_NAMESPACE_BEGIN
19class VTKCOMMONCORE_EXPORT vtkVoidArray : public vtkObject
20{
21public:
25 static vtkVoidArray* New();
27
28 vtkTypeMacro(vtkVoidArray, vtkObject);
29 void PrintSelf(ostream& os, vtkIndent indent) override;
30
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
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
116
117protected:
119 ~vtkVoidArray() override;
120
123 void** Array; // pointer to data
124
125 void** ResizeAndExtend(vtkIdType sz); // function to resize data
126
127private:
128 vtkVoidArray(const vtkVoidArray&) = delete;
129 void operator=(const vtkVoidArray&) = delete;
130};
131
132VTK_ABI_NAMESPACE_END
133#endif
a simple class to control print indentation
Definition vtkIndent.h:108
abstract base class for most VTK objects
Definition vtkObject.h:162
dynamic, self-adjusting array of void* pointers
vtkIdType InsertNextVoidPointer(void *tuple)
Insert (memory allocation performed) the void* pointer at the end of the array.
void ** GetPointer(vtkIdType id)
Get the address of a particular data index.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void Squeeze()
Resize the array to just fit the inserted memory.
static vtkVoidArray * New()
Initialize with empty array.
~vtkVoidArray() override
void ** ResizeAndExtend(vtkIdType sz)
void SetVoidPointer(vtkIdType id, void *ptr)
Set the void* pointer value at the ith location in the array.
void SetNumberOfPointers(vtkIdType number)
Set the number of void* pointers held in the array.
void Initialize()
Release storage and reset array to initial state.
void ** WritePointer(vtkIdType id, vtkIdType number)
Get the address of a particular data index.
vtkIdType GetNumberOfPointers()
Get the number of void* pointers held in the array.
vtkIdType NumberOfPointers
void InsertVoidPointer(vtkIdType i, void *ptr)
Insert (memory allocation performed) the void* into the ith location in the array.
void Reset()
Reuse already allocated data; make the container look like it is empty.
void DeepCopy(vtkVoidArray *va)
Deep copy of another void array.
void * GetVoidPointer(vtkIdType id)
Get the void* pointer at the ith location.
int GetDataType() const
Return the type of data.
vtkIdType Size
vtkTypeBool Allocate(vtkIdType sz, vtkIdType ext=1000)
Allocate memory for this array.
int GetDataTypeSize()
Return the size of the data contained in the array.
static vtkVoidArray * ExtendedNew()
int vtkTypeBool
Definition vtkABI.h:64
int vtkIdType
Definition vtkType.h:315
#define VTK_VOID
Definition vtkType.h:31