14#ifndef POINTERTOARRAY_H
15#define POINTERTOARRAY_H
64#if (defined(WIN32_VC) || defined(WIN64_VC)) && !defined(__INTEL_COMPILER)
67#pragma warning (disable : 4506)
70template <
class Element>
86template <
class Element>
87class PointerToArray :
public PointerToArrayBase<Element> {
94 typedef typename pvector<Element>::size_type size_type;
95 INLINE PointerToArray(
TypeHandle type_handle = get_type_handle(Element));
96 INLINE
static PointerToArray<Element>
empty_array(size_type n,
TypeHandle type_handle = get_type_handle(Element));
97 INLINE PointerToArray(
const PointerToArray<Element> ©);
99 EXTENSION(PointerToArray(PyObject *self, PyObject *source));
103 INLINE size_type size()
const;
104 INLINE
void push_back(
const Element &x);
105 INLINE
void pop_back();
106 INLINE
const Element &
get_element(size_type n)
const;
107 INLINE
void set_element(size_type n,
const Element &value);
108 EXTENSION(
const Element &__getitem__(size_type n)
const);
109 EXTENSION(
void __setitem__(size_type n,
const Element &value));
110 EXTENSION(PyObject *
get_data()
const);
111 EXTENSION(
void set_data(PyObject *data));
113 INLINE
void set_subdata(size_type n, size_type
count,
const std::string &data);
117 INLINE
size_t count(
const Element &)
const;
120 EXTENSION(PyObject *__reduce__(PyObject *self)
const);
122 EXTENSION(
int __getbuffer__(PyObject *self, Py_buffer *view,
int flags));
123 EXTENSION(
void __releasebuffer__(PyObject *self, Py_buffer *view)
const);
125 EXTENSION(PointerToArray<Element> __deepcopy__(PyObject *memo)
const);
130 typedef typename PointerToArrayBase<Element>::To To;
131 typedef typename pvector<Element>::value_type value_type;
132 typedef typename pvector<Element>::reference reference;
133 typedef typename pvector<Element>::const_reference const_reference;
134 typedef typename pvector<Element>::iterator iterator;
135 typedef typename pvector<Element>::const_iterator const_iterator;
136 typedef typename pvector<Element>::reverse_iterator reverse_iterator;
137 typedef typename pvector<Element>::const_reverse_iterator const_reverse_iterator;
138 typedef typename pvector<Element>::difference_type difference_type;
139 typedef typename pvector<Element>::size_type size_type;
142 INLINE PointerToArray(
TypeHandle type_handle = get_type_handle(Element));
144 INLINE PointerToArray(size_type n,
const Element &value,
TypeHandle type_handle = get_type_handle(Element));
146 INLINE PointerToArray(
const PointerToArray<Element> ©);
147 INLINE PointerToArray(PointerToArray<Element> &&from)
noexcept;
155 INLINE iterator begin()
const;
156 INLINE iterator end()
const;
157 INLINE
typename PointerToArray<Element>::reverse_iterator rbegin()
const;
158 INLINE
typename PointerToArray<Element>::reverse_iterator rend()
const;
162 INLINE size_type size()
const;
163 INLINE size_type max_size()
const;
164 INLINE
bool empty()
const;
169 INLINE
void reserve(size_type n);
170 INLINE
void resize(size_type n);
171 INLINE size_type capacity()
const;
172 INLINE reference front()
const;
173 INLINE reference back()
const;
174 INLINE iterator insert(iterator position,
const Element &x);
175 INLINE
void insert(iterator position, size_type n,
const Element &x);
183 INLINE
void erase(iterator position);
184 INLINE
void erase(iterator first, iterator last);
186#if !defined(WIN32_VC) && !defined (WIN64_VC)
187 INLINE reference operator [](size_type n)
const;
188 INLINE reference operator [](
int n)
const;
191 INLINE
void push_back(
const Element &x);
192 INLINE
void pop_back();
195 INLINE
operator Element *()
const;
196 INLINE Element *
p()
const;
197 INLINE pvector<Element> &
v()
const;
225 INLINE
size_t count(
const Element &)
const;
231 INLINE PointerToArray<Element> &
233 INLINE PointerToArray<Element> &
234 operator = (
const PointerToArray<Element> ©);
235 INLINE PointerToArray<Element> &
236 operator = (PointerToArray<Element> &&from)
noexcept;
245 static pvector<Element> _empty_array;
253template <
class Element>
254class ConstPointerToArray :
public PointerToArrayBase<Element> {
256 INLINE ConstPointerToArray(
TypeHandle type_handle = get_type_handle(Element));
264 INLINE ConstPointerToArray(
const ConstPointerToArray<Element> ©);
268 typedef typename pvector<Element>::size_type size_type;
269 INLINE size_type size()
const;
270 INLINE
const Element &
get_element(size_type n)
const;
271 EXTENSION(
const Element &__getitem__(size_type n)
const);
272 EXTENSION(PyObject *
get_data()
const);
277 INLINE
size_t count(
const Element &)
const;
280 EXTENSION(PyObject *__reduce__(PyObject *self)
const);
282 EXTENSION(
int __getbuffer__(PyObject *self, Py_buffer *view,
int flags)
const);
283 EXTENSION(
void __releasebuffer__(PyObject *self, Py_buffer *view)
const);
285 EXTENSION(ConstPointerToArray<Element> __deepcopy__(PyObject *memo)
const);
290 typedef typename PointerToArrayBase<Element>::To To;
291 typedef typename pvector<Element>::value_type value_type;
292 typedef typename pvector<Element>::const_reference reference;
293 typedef typename pvector<Element>::const_reference const_reference;
294 typedef typename pvector<Element>::const_iterator iterator;
295 typedef typename pvector<Element>::const_iterator const_iterator;
296#if defined(WIN32_VC) || defined(WIN64_VC)
298 typedef typename pvector<Element>::reverse_iterator reverse_iterator;
300 typedef typename pvector<Element>::const_reverse_iterator reverse_iterator;
302 typedef typename pvector<Element>::const_reverse_iterator const_reverse_iterator;
303 typedef typename pvector<Element>::difference_type difference_type;
304 typedef typename pvector<Element>::size_type size_type;
308 INLINE ConstPointerToArray(
const ConstPointerToArray<Element> ©);
310 INLINE ConstPointerToArray(ConstPointerToArray<Element> &&from)
noexcept;
315 INLINE iterator begin()
const;
316 INLINE iterator end()
const;
317 INLINE
typename ConstPointerToArray<Element>::reverse_iterator rbegin()
const;
318 INLINE
typename ConstPointerToArray<Element>::reverse_iterator rend()
const;
323 INLINE size_type size()
const;
324 INLINE size_type max_size()
const;
325 INLINE
bool empty()
const;
330 INLINE size_type capacity()
const;
331 INLINE reference front()
const;
332 INLINE reference back()
const;
334#if !defined(WIN32_VC) && !defined(WIN64_VC)
335 INLINE reference operator [](size_type n)
const;
336 INLINE reference operator [](
int n)
const;
339 INLINE
operator const Element *()
const;
340 INLINE
const Element *
p()
const;
341 INLINE
const pvector<Element> &
v()
const;
358 INLINE
size_t count(
const Element &)
const;
364 INLINE ConstPointerToArray<Element> &
366 INLINE ConstPointerToArray<Element> &
368 INLINE ConstPointerToArray<Element> &
369 operator = (
const ConstPointerToArray<Element> ©);
370 INLINE ConstPointerToArray<Element> &
372 INLINE ConstPointerToArray<Element> &
373 operator = (ConstPointerToArray<Element> &&from)
noexcept;
382 static pvector<Element> _empty_array;
388#define PTA(type) PointerToArray< type >
389#define CPTA(type) ConstPointerToArray< type >
Similar to PointerToArray, except that its contents may not be modified.
int get_ref_count() const
Returns the reference count of the underlying vector.
std::string get_data() const
This method exists mainly to access the data of the array easily from a high-level language such as P...
bool node_unref() const
Decrements the node_ref of the underlying vector.
const Element * p() const
Function p() is similar to the function from ConstPointerTo.
ConstPointerToArray(pvector< Element > &&from, TypeHandle type_handle=get_type_handle(Element))
Initializes the PTA from a vector.
void clear()
To empty the PTA, use the clear() method, since assignment to NULL is problematic (given the ambiguit...
std::string get_subdata(size_type n, size_type count) const
This method exists mainly to access the data of the array easily from a high-level language such as P...
const ReferenceCountedVector< Element > * v0() const
To access the internal ReferenceCountedVector object, for very low-level fiddling.
size_t count(const Element &) const
Counts the frequency at which the given element occurs in the vector.
void node_ref() const
Increments the node_ref of the underlying vector.
int get_node_ref_count() const
Returns the node_ref of the underlying vector.
const pvector< Element > & v() const
To access the vector itself, for more direct fiddling with some of the vector's esoteric functionalit...
ConstPointerToArray(const Element *begin, const Element *end, TypeHandle type_handle=get_type_handle(Element))
Initializes a ConstPointerToArray by copying existing elements.
bool unref() const
Decrements the reference count of the underlying vector.
const Element & get_element(size_type n) const
This method exists mainly to access the elements of the array easily from a high-level language such ...
PointerToArray< Element > cast_non_const() const
Casts away the constness of the CPTA(Element), and returns an equivalent PTA(Element).
void ref() const
Increments the reference count of the underlying vector.
A special kind of PointerTo that stores an array of the indicated element type, instead of a single e...
void set_data(const std::string &data)
This method exists mainly to access the data of the array easily from a high-level language such as P...
size_t count(const Element &) const
Counts the frequency at which the given element occurs in the vector.
pvector< Element > & v() const
To access the vector itself, for more direct fiddling with some of the vector's esoteric functionalit...
void set_void_ptr(void *p)
Sets this PTA to point to the pointer passed in.
std::string get_subdata(size_type n, size_type count) const
This method exists mainly to access the data of the array easily from a high-level language such as P...
int get_ref_count() const
Returns the reference count of the underlying vector.
PointerToArray(const Element *begin, const Element *end, TypeHandle type_handle=get_type_handle(Element))
Initializes a PointerToArray by copying existing elements.
static PointerToArray< Element > empty_array(size_type n, TypeHandle type_handle=get_type_handle(Element))
Return an empty array of size n.
void set_subdata(size_type n, size_type count, const std::string &data)
This method exists mainly to access the data of the array easily from a high-level language such as P...
PointerToArray(pvector< Element > &&from, TypeHandle type_handle=get_type_handle(Element))
Initializes the PTA from a vector.
ReferenceCountedVector< Element > * v0() const
To access the internal ReferenceCountedVector object, for very low-level fiddling.
int get_node_ref_count() const
Returns the node_ref of the underlying vector.
const Element & get_element(size_type n) const
This method exists mainly to access the elements of the array easily from a high-level language such ...
void clear()
To empty the PTA, use the clear() method, since assignment to NULL is problematic (given the ambiguit...
void set_element(size_type n, const Element &value)
This method exists mainly to access the elements of the array easily from a high-level language such ...
void * get_void_ptr() const
Returns the reference to memory where the vector is stored.
void ref() const
Increments the reference count of the underlying vector.
void make_empty()
Empties the array pointed to.
bool unref() const
Decrements the reference count of the underlying vector.
Element * p() const
Function p() is similar to the function from PointerTo.
bool node_unref() const
Decrements the node_ref of the underlying vector.
void node_ref() const
Increments the node_ref of the underlying vector.
std::string get_data() const
This method exists mainly to access the data of the array easily from a high-level language such as P...
This defines the object that is actually stored and reference-counted internally by a PointerToArray.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.