Panda3D
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
PointerToArray< Element > Class Template Reference

A special kind of PointerTo that stores an array of the indicated element type, instead of a single element. More...

#include "pointerToArray.h"

Inheritance diagram for PointerToArray< Element >:
PointerToArrayBase< Element > PointerToBase< ReferenceCountedVector< Element > > PointerToVoid MemoryBase

Public Types

typedef pvector< Element >::const_iterator const_iterator
 
typedef pvector< Element >::const_reference const_reference
 
typedef pvector< Element >::const_reverse_iterator const_reverse_iterator
 
typedef pvector< Element >::difference_type difference_type
 
typedef pvector< Element >::iterator iterator
 
typedef pvector< Element >::reference reference
 
typedef pvector< Element >::reverse_iterator reverse_iterator
 
typedef pvector< Element >::size_type size_type
 
typedef PointerToArrayBase< Element >::To To
 
typedef pvector< Element >::value_type value_type
 
- Public Types inherited from PointerToArrayBase< Element >
typedef PointerToBase< ReferenceCountedVector< Element > >::To To
 
- Public Types inherited from PointerToBase< ReferenceCountedVector< Element > >
typedef ReferenceCountedVector< Element > To
 

Public Member Functions

 PointerToArray (const Element *begin, const Element *end, TypeHandle type_handle=get_type_handle(Element))
 Initializes a PointerToArray by copying existing elements.
 
 PointerToArray (const PointerToArray< Element > &copy)
 
 PointerToArray (PointerToArray< Element > &&from) noexcept
 
 PointerToArray (pvector< Element > &&from, TypeHandle type_handle=get_type_handle(Element))
 Initializes the PTA from a vector.
 
 PointerToArray (size_type n, const Element &value, TypeHandle type_handle=get_type_handle(Element))
 
 PointerToArray (TypeHandle type_handle=get_type_handle(Element))
 
reference back () const
 
iterator begin () const
 
size_type capacity () const
 
void clear ()
 To empty the PTA, use the clear() method, since assignment to NULL is problematic (given the ambiguity of the pointer type of NULL).
 
size_t count (const Element &) const
 Counts the frequency at which the given element occurs in the vector.
 
bool empty () const
 
iterator end () const
 
void erase (iterator first, iterator last)
 
void erase (iterator position)
 
reference front () const
 
std::string get_data () const
 This method exists mainly to access the data of the array easily from a high-level language such as Python.
 
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 as Python, especially on Windows, where the above index element accessor methods can't be defined because of a confusion with the pointer typecast operator.
 
int get_node_ref_count () const
 Returns the node_ref of the underlying vector.
 
int get_ref_count () const
 Returns the reference count of the underlying vector.
 
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 Python.
 
void * get_void_ptr () const
 Returns the reference to memory where the vector is stored.
 
iterator insert (iterator position, const Element &x)
 
void insert (iterator position, size_type n, const Element &x)
 
void make_empty ()
 Empties the array pointed to.
 
size_type max_size () const
 
void node_ref () const
 Increments the node_ref of the underlying vector.
 
bool node_unref () const
 Decrements the node_ref of the underlying vector.
 
 operator Element * () const
 The pointer typecast operator is convenient for maintaining the fiction that we actually have a C-style array.
 
PointerToArray< Element > & operator= (const PointerToArray< Element > &copy)
 
PointerToArray< Element > & operator= (PointerToArray< Element > &&from) noexcept
 
PointerToArray< Element > & operator= (ReferenceCountedVector< Element > *ptr)
 
reference operator[] (int n) const
 
reference operator[] (size_type n) const
 
Element * p () const
 Function p() is similar to the function from PointerTo.
 
void pop_back ()
 
void push_back (const Element &x)
 
PointerToArray< Element >::reverse_iterator rbegin () const
 
void ref () const
 Increments the reference count of the underlying vector.
 
PointerToArray< Element >::reverse_iterator rend () const
 
void reserve (size_type n)
 
void resize (size_type n)
 
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 Python.
 
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 as Python, especially on Windows, where the above index element accessor methods can't be defined because of a confusion with the pointer typecast operator.
 
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 Python.
 
void set_void_ptr (void *p)
 Sets this PTA to point to the pointer passed in.
 
size_type size () const
 
bool unref () const
 Decrements the reference count of the underlying vector.
 
pvector< Element > & v () const
 To access the vector itself, for more direct fiddling with some of the vector's esoteric functionality.
 
ReferenceCountedVector< Element > * v0 () const
 To access the internal ReferenceCountedVector object, for very low-level fiddling.
 
- Public Member Functions inherited from PointerToBase< ReferenceCountedVector< Element > >
void clear ()
 A convenient way to set the PointerTo object to NULL.
 
void output (std::ostream &out) const
 A handy function to output PointerTo's as a hex pointer followed by a reference count.
 
- Public Member Functions inherited from PointerToVoid
size_t get_hash () const
 
constexpr bool is_null () const
 Returns true if the PointerTo is a NULL pointer, false otherwise.
 
bool operator!= (const PointerToVoid &other) const
 
bool operator< (const PointerToVoid &other) const
 
bool operator< (const void *other) const
 
bool operator== (const PointerToVoid &other) const
 
void swap (PointerToVoid &other) noexcept
 Swaps the contents of this PointerTo with the other, without touching the reference counts.
 
- Public Member Functions inherited from MemoryBase
void operator delete (void *, void *)
 
void operator delete (void *ptr)
 
void operator delete[] (void *, void *)
 
void operator delete[] (void *ptr)
 
void * operator new (size_t size)
 
void * operator new (size_t size, void *ptr)
 
void * operator new[] (size_t size)
 
void * operator new[] (size_t size, void *ptr)
 

Static Public Member Functions

static PointerToArray< Element > empty_array (size_type n, TypeHandle type_handle=get_type_handle(Element))
 Return an empty array of size n.
 

Friends

class ConstPointerToArray< Element >
 

Detailed Description

template<class Element>
class PointerToArray< Element >

A special kind of PointerTo that stores an array of the indicated element type, instead of a single element.

This is actually implemented as an STL vector, using the RefCountObj class to wrap it up with a reference count.

We actually inherit from NodeRefCountObj these days, which adds node_ref() and node_unref() to the standard ref() and unref(). This is particularly useful for GeomVertexArrayData; other classes may or may not find this additional counter useful, but since it adds relatively little overhead (compared with what is presumably a largish array), we go ahead and add it here, even though it is inherited by many different parts of the system that may not use it.

Definition at line 87 of file pointerToArray.h.

Member Typedef Documentation

◆ const_iterator

template<class Element >
typedef pvector<Element>::const_iterator PointerToArray< Element >::const_iterator

Definition at line 135 of file pointerToArray.h.

◆ const_reference

template<class Element >
typedef pvector<Element>::const_reference PointerToArray< Element >::const_reference

Definition at line 133 of file pointerToArray.h.

◆ const_reverse_iterator

template<class Element >
typedef pvector<Element>::const_reverse_iterator PointerToArray< Element >::const_reverse_iterator

Definition at line 137 of file pointerToArray.h.

◆ difference_type

template<class Element >
typedef pvector<Element>::difference_type PointerToArray< Element >::difference_type

Definition at line 138 of file pointerToArray.h.

◆ iterator

template<class Element >
typedef pvector<Element>::iterator PointerToArray< Element >::iterator

Definition at line 134 of file pointerToArray.h.

◆ reference

template<class Element >
typedef pvector<Element>::reference PointerToArray< Element >::reference

Definition at line 132 of file pointerToArray.h.

◆ reverse_iterator

template<class Element >
typedef pvector<Element>::reverse_iterator PointerToArray< Element >::reverse_iterator

Definition at line 136 of file pointerToArray.h.

◆ size_type

template<class Element >
typedef pvector<Element>::size_type PointerToArray< Element >::size_type

Definition at line 139 of file pointerToArray.h.

◆ To

template<class Element >
typedef PointerToArrayBase<Element>::To PointerToArray< Element >::To

Definition at line 130 of file pointerToArray.h.

◆ value_type

template<class Element >
typedef pvector<Element>::value_type PointerToArray< Element >::value_type

Definition at line 131 of file pointerToArray.h.

Constructor & Destructor Documentation

◆ PointerToArray() [1/6]

template<class Element >
PointerToArray< Element >::PointerToArray ( TypeHandle type_handle = get_type_handle(Element))
inline

Definition at line 26 of file pointerToArray.I.

◆ PointerToArray() [2/6]

template<class Element >
PointerToArray< Element >::PointerToArray ( size_type n,
const Element & value,
TypeHandle type_handle = get_type_handle(Element) )
inline

Definition at line 51 of file pointerToArray.I.

◆ PointerToArray() [3/6]

template<class Element >
PointerToArray< Element >::PointerToArray ( const Element * begin,
const Element * end,
TypeHandle type_handle = get_type_handle(Element) )
inline

Initializes a PointerToArray by copying existing elements.

Definition at line 75 of file pointerToArray.I.

◆ PointerToArray() [4/6]

template<class Element >
PointerToArray< Element >::PointerToArray ( const PointerToArray< Element > & copy)
inline

Definition at line 64 of file pointerToArray.I.

◆ PointerToArray() [5/6]

template<class Element >
PointerToArray< Element >::PointerToArray ( PointerToArray< Element > && from)
inlinenoexcept

Definition at line 86 of file pointerToArray.I.

◆ PointerToArray() [6/6]

template<class Element >
PointerToArray< Element >::PointerToArray ( pvector< Element > && from,
TypeHandle type_handle = get_type_handle(Element) )
inlineexplicit

Initializes the PTA from a vector.

Definition at line 97 of file pointerToArray.I.

Member Function Documentation

◆ back()

template<class Element >
PointerToArray< Element >::reference PointerToArray< Element >::back ( ) const
inline

Definition at line 235 of file pointerToArray.I.

◆ begin()

template<class Element >
PointerToArray< Element >::iterator PointerToArray< Element >::begin ( ) const
inline

Definition at line 108 of file pointerToArray.I.

◆ capacity()

template<class Element >
PointerToArray< Element >::size_type PointerToArray< Element >::capacity ( ) const
inline

Definition at line 210 of file pointerToArray.I.

◆ clear()

template<class Element >
void PointerToArray< Element >::clear ( )
inline

To empty the PTA, use the clear() method, since assignment to NULL is problematic (given the ambiguity of the pointer type of NULL).

Definition at line 643 of file pointerToArray.I.

◆ count()

template<class Element >
size_t PointerToArray< Element >::count ( const Element & value) const
inline

Counts the frequency at which the given element occurs in the vector.

Definition at line 597 of file pointerToArray.I.

◆ empty()

template<class Element >
bool PointerToArray< Element >::empty ( ) const
inline

Definition at line 177 of file pointerToArray.I.

◆ empty_array()

template<class Element >
PointerToArray< Element > PointerToArray< Element >::empty_array ( size_type n,
TypeHandle type_handle = get_type_handle(Element) )
inlinestatic

Return an empty array of size n.

Definition at line 38 of file pointerToArray.I.

◆ end()

template<class Element >
PointerToArray< Element >::iterator PointerToArray< Element >::end ( ) const
inline

Definition at line 120 of file pointerToArray.I.

◆ erase() [1/2]

template<class Element >
void PointerToArray< Element >::erase ( iterator first,
iterator last )
inline

Definition at line 292 of file pointerToArray.I.

◆ erase() [2/2]

template<class Element >
void PointerToArray< Element >::erase ( iterator position)
inline

Definition at line 280 of file pointerToArray.I.

◆ front()

template<class Element >
PointerToArray< Element >::reference PointerToArray< Element >::front ( ) const
inline

Definition at line 220 of file pointerToArray.I.

◆ get_data()

template<class Element >
std::string PointerToArray< Element >::get_data ( ) const
inline

This method exists mainly to access the data of the array easily from a high-level language such as Python.

It returns the entire contents of the vector as a block of raw data in a string.

Definition at line 446 of file pointerToArray.I.

◆ get_element()

template<class Element >
const Element & PointerToArray< Element >::get_element ( size_type n) const
inline

This method exists mainly to access the elements of the array easily from a high-level language such as Python, especially on Windows, where the above index element accessor methods can't be defined because of a confusion with the pointer typecast operator.

Definition at line 420 of file pointerToArray.I.

◆ get_node_ref_count()

template<class Element >
int PointerToArray< Element >::get_node_ref_count ( ) const
inline

Returns the node_ref of the underlying vector.

Definition at line 566 of file pointerToArray.I.

◆ get_ref_count()

template<class Element >
int PointerToArray< Element >::get_ref_count ( ) const
inline

Returns the reference count of the underlying vector.

Definition at line 535 of file pointerToArray.I.

◆ get_subdata()

template<class Element >
std::string PointerToArray< Element >::get_subdata ( size_type n,
size_type count ) const
inline

This method exists mainly to access the data of the array easily from a high-level language such as Python.

It returns the contents of a portion of the vector–from element (n) through element (n + count - 1)–as a block of raw data in a string.

Definition at line 472 of file pointerToArray.I.

◆ get_void_ptr()

template<class Element >
void * PointerToArray< Element >::get_void_ptr ( ) const
inline

Returns the reference to memory where the vector is stored.

To be used only with set_void_ptr

Definition at line 517 of file pointerToArray.I.

◆ insert() [1/2]

template<class Element >
PointerToArray< Element >::iterator PointerToArray< Element >::insert ( iterator position,
const Element & x )
inline

Definition at line 250 of file pointerToArray.I.

◆ insert() [2/2]

template<class Element >
void PointerToArray< Element >::insert ( iterator position,
size_type n,
const Element & x )
inline

Definition at line 265 of file pointerToArray.I.

◆ make_empty()

template<class Element >
void PointerToArray< Element >::make_empty ( )
inline

Empties the array pointed to.

This is different from clear(), which reassigns the pointer to a NULL pointer.

Definition at line 357 of file pointerToArray.I.

◆ max_size()

template<class Element >
PointerToArray< Element >::size_type PointerToArray< Element >::max_size ( ) const
inline

Definition at line 165 of file pointerToArray.I.

◆ node_ref()

template<class Element >
void PointerToArray< Element >::node_ref ( ) const
inline

Increments the node_ref of the underlying vector.

Definition at line 575 of file pointerToArray.I.

◆ node_unref()

template<class Element >
bool PointerToArray< Element >::node_unref ( ) const
inline

Decrements the node_ref of the underlying vector.

Definition at line 587 of file pointerToArray.I.

◆ operator Element *()

template<class Element >
PointerToArray< Element >::operator Element * ( ) const
inline

The pointer typecast operator is convenient for maintaining the fiction that we actually have a C-style array.

It returns the address of the first element in the array, unless the pointer is unassigned, in which case it returns NULL.

Definition at line 373 of file pointerToArray.I.

◆ operator=() [1/3]

template<class Element >
PointerToArray< Element > & PointerToArray< Element >::operator= ( const PointerToArray< Element > & copy)
inline

Definition at line 620 of file pointerToArray.I.

◆ operator=() [2/3]

template<class Element >
PointerToArray< Element > & PointerToArray< Element >::operator= ( PointerToArray< Element > && from)
inlinenoexcept

Definition at line 631 of file pointerToArray.I.

◆ operator=() [3/3]

template<class Element >
PointerToArray< Element > & PointerToArray< Element >::operator= ( ReferenceCountedVector< Element > * ptr)
inline

Definition at line 610 of file pointerToArray.I.

◆ operator[]() [1/2]

template<class Element >
PointerToArray< Element >::reference PointerToArray< Element >::operator[] ( int n) const
inline

Definition at line 321 of file pointerToArray.I.

◆ operator[]() [2/2]

template<class Element >
PointerToArray< Element >::reference PointerToArray< Element >::operator[] ( size_type n) const
inline

Definition at line 305 of file pointerToArray.I.

◆ p()

template<class Element >
Element * PointerToArray< Element >::p ( ) const
inline

Function p() is similar to the function from PointerTo.

It does the same thing: it returns the same thing as the typecast operator, above.

Definition at line 384 of file pointerToArray.I.

◆ pop_back()

template<class Element >
void PointerToArray< Element >::pop_back ( )
inline

Definition at line 343 of file pointerToArray.I.

◆ push_back()

template<class Element >
void PointerToArray< Element >::push_back ( const Element & x)
inline

Definition at line 331 of file pointerToArray.I.

◆ rbegin()

template<class Element >
PointerToArray< Element >::reverse_iterator PointerToArray< Element >::rbegin ( ) const
inline

Definition at line 132 of file pointerToArray.I.

◆ ref()

template<class Element >
void PointerToArray< Element >::ref ( ) const
inline

Increments the reference count of the underlying vector.

Definition at line 544 of file pointerToArray.I.

◆ rend()

template<class Element >
PointerToArray< Element >::reverse_iterator PointerToArray< Element >::rend ( ) const
inline

Definition at line 144 of file pointerToArray.I.

◆ reserve()

template<class Element >
void PointerToArray< Element >::reserve ( size_type n)
inline

Definition at line 186 of file pointerToArray.I.

◆ resize()

template<class Element >
void PointerToArray< Element >::resize ( size_type n)
inline

Definition at line 198 of file pointerToArray.I.

◆ set_data()

template<class Element >
void PointerToArray< Element >::set_data ( const std::string & data)
inline

This method exists mainly to access the data of the array easily from a high-level language such as Python.

It replaces the entire contents of the vector from a block of raw data in a string.

Definition at line 459 of file pointerToArray.I.

◆ set_element()

template<class Element >
void PointerToArray< Element >::set_element ( size_type n,
const Element & value )
inline

This method exists mainly to access the elements of the array easily from a high-level language such as Python, especially on Windows, where the above index element accessor methods can't be defined because of a confusion with the pointer typecast operator.

Definition at line 432 of file pointerToArray.I.

◆ set_subdata()

template<class Element >
void PointerToArray< Element >::set_subdata ( size_type n,
size_type count,
const std::string & data )
inline

This method exists mainly to access the data of the array easily from a high-level language such as Python.

It replaces the contents of a portion of the vector–from element (n) through element (n + count - 1)–as a block of raw data in a string. The length of the string must be an even multiple of Element size bytes. The array may be expanded or truncated if the length of the string does not correspond to exactly count elements.

Definition at line 491 of file pointerToArray.I.

◆ set_void_ptr()

template<class Element >
void PointerToArray< Element >::set_void_ptr ( void * p)
inline

Sets this PTA to point to the pointer passed in.

Definition at line 526 of file pointerToArray.I.

◆ size()

template<class Element >
PointerToArray< Element >::size_type PointerToArray< Element >::size ( ) const
inline

Definition at line 156 of file pointerToArray.I.

◆ unref()

template<class Element >
bool PointerToArray< Element >::unref ( ) const
inline

Decrements the reference count of the underlying vector.

Definition at line 556 of file pointerToArray.I.

◆ v()

template<class Element >
pvector< Element > & PointerToArray< Element >::v ( ) const
inline

To access the vector itself, for more direct fiddling with some of the vector's esoteric functionality.

Definition at line 395 of file pointerToArray.I.

◆ v0()

template<class Element >
ReferenceCountedVector< Element > * PointerToArray< Element >::v0 ( ) const
inline

To access the internal ReferenceCountedVector object, for very low-level fiddling.

Know what you are doing!

Definition at line 408 of file pointerToArray.I.

Friends And Related Symbol Documentation

◆ ConstPointerToArray< Element >

template<class Element >
friend class ConstPointerToArray< Element >
friend

Definition at line 245 of file pointerToArray.h.


The documentation for this class was generated from the following files: