17 template<
class Element>
20 template<
class Element>
28 template<
class Element>
32 _type_handle(type_handle)
41 template<
class Element>
47 To new_array(n, type_handle);
48 ((To *)(temp._void_ptr))->
swap(new_array);
57 template<
class Element>
61 _type_handle(type_handle)
63 ((To *)(this->_void_ptr))->reserve(n);
64 insert(begin(), n, value);
72 template<
class Element>
76 _type_handle(copy._type_handle)
80 #ifdef USE_MOVE_SEMANTICS 86 template<
class Element>
90 _type_handle(from._type_handle)
93 #endif // USE_MOVE_SEMANTICS 100 template<
class Element>
103 if ((this->_void_ptr) == NULL) {
104 return _empty_array.begin();
106 return ((To *)(this->_void_ptr))->begin();
114 template<
class Element>
117 if ((this->_void_ptr) == NULL) {
118 return _empty_array.begin();
120 return ((To *)(this->_void_ptr))->end();
128 template<
class Element>
131 if ((this->_void_ptr) == NULL) {
132 return _empty_array.rbegin();
134 return ((To *)(this->_void_ptr))->rbegin();
142 template<
class Element>
145 if ((this->_void_ptr) == NULL) {
146 return _empty_array.rbegin();
148 return ((To *)(this->_void_ptr))->rend();
156 template<
class Element>
159 return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->size();
167 template<
class Element>
170 nassertd((this->_void_ptr) != NULL) {
173 return ((To *)(this->_void_ptr))->max_size();
181 template<
class Element>
184 return ((this->_void_ptr) == NULL) ? true : ((To *)(this->_void_ptr))->empty();
192 template<
class Element>
194 reserve(TYPENAME PointerToArray<Element>::size_type n) {
195 if ((this->_void_ptr) == NULL) {
198 ((To *)(this->_void_ptr))->reserve(n);
206 template<
class Element>
208 resize(TYPENAME PointerToArray<Element>::size_type n) {
209 if ((this->_void_ptr) == NULL) {
212 ((To *)(this->_void_ptr))->resize(n);
220 template<
class Element>
223 nassertr((this->_void_ptr) != NULL, 0);
224 return ((To *)(this->_void_ptr))->capacity();
232 template<
class Element>
235 nassertd((this->_void_ptr) != NULL) {
238 nassertd(!((To *)(this->_void_ptr))->empty()) {
239 ((To *)(this->_void_ptr))->push_back(Element());
241 return ((To *)(this->_void_ptr))->front();
249 template<
class Element>
252 nassertd((this->_void_ptr) != NULL) {
255 nassertd(!((To *)(this->_void_ptr))->empty()) {
256 ((To *)(this->_void_ptr))->push_back(Element());
258 return ((To *)(this->_void_ptr))->back();
266 template<
class Element>
268 insert(iterator position,
const Element &x) {
269 if ((this->_void_ptr) == NULL) {
273 nassertr(position >= ((To *)(this->_void_ptr))->begin() &&
274 position <= ((To *)(this->_void_ptr))->end(), position);
275 return ((To *)(this->_void_ptr))->insert(position, x);
283 template<
class Element>
285 insert(iterator position, size_type n,
const Element &x) {
286 if ((this->_void_ptr) == NULL) {
290 nassertv(position >= ((To *)(this->_void_ptr))->begin() &&
291 position <= ((To *)(this->_void_ptr))->end());
292 ((To *)(this->_void_ptr))->insert(position, n, x);
300 template<
class Element>
302 erase(iterator position) {
303 nassertv((this->_void_ptr) != NULL);
304 nassertv(position >= ((To *)(this->_void_ptr))->begin() &&
305 position <= ((To *)(this->_void_ptr))->end());
306 ((To *)(this->_void_ptr))->erase(position);
314 template<
class Element>
316 erase(iterator first, iterator last) {
317 nassertv((this->_void_ptr) != NULL);
318 nassertv(first >= ((To *)(this->_void_ptr))->begin() && first <= ((To *)(this->_void_ptr))->end());
319 nassertv(last >= ((To *)(this->_void_ptr))->begin() && last <= ((To *)(this->_void_ptr))->end());
320 ((To *)(this->_void_ptr))->erase(first, last);
323 #if !defined(WIN32_VC) && !defined(WIN64_VC) 329 template<
class Element>
332 nassertd((this->_void_ptr) != NULL) {
335 nassertd(!((To *)(this->_void_ptr))->empty()) {
336 ((To *)(this->_void_ptr))->push_back(Element());
338 nassertr(n < ((To *)(this->_void_ptr))->size(), ((To *)(this->_void_ptr))->
operator[](0));
339 return ((To *)(this->_void_ptr))->operator[](n);
347 template<
class Element>
350 return operator[]((size_type)n);
359 template<
class Element>
362 if ((this->_void_ptr) == NULL) {
365 ((To *)(this->_void_ptr))->push_back(x);
373 template<
class Element>
376 nassertd((this->_void_ptr) != NULL) {
379 nassertv(!((To *)(this->_void_ptr))->empty());
380 ((To *)(this->_void_ptr))->pop_back();
390 template<
class Element>
393 nassertd((this->_void_ptr) != NULL) {
396 nassertv(!((To *)(this->_void_ptr))->empty());
397 ((To *)(this->_void_ptr))->
clear();
409 template<
class Element>
411 operator Element *()
const {
412 To *vec = (To *)(this->_void_ptr);
413 return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front());
423 template<
class Element>
426 To *vec = (To *)(this->_void_ptr);
427 return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front());
436 template<
class Element>
439 if ((this->_void_ptr) == NULL) {
442 return *((To *)(this->_void_ptr));
451 template<
class Element>
454 return (To *)(this->_void_ptr);
466 template<
class Element>
481 template<
class Element>
484 nassertv(n < ((To *)(this->_void_ptr))->size());
498 template<
class Element>
514 template<
class Element>
531 template<
class Element>
535 count = max(count, n);
536 count = min(count, size() - n);
537 return string((
const char *)(
p() + n),
sizeof(Element) * count);
555 template<
class Element>
558 nassertv((data.length() %
sizeof(Element)) == 0);
559 nassertv(n <= size() && n + count <= size());
560 if ((this->_void_ptr) == NULL) {
563 size_type ncount = data.length() /
sizeof(Element);
564 if (ncount < count) {
566 erase(begin() + n + ncount, begin() + n + count);
567 }
else if (count < ncount) {
569 insert(begin() + n + count, ncount - count, Element());
575 memcpy(
p() + n, data.data(),
sizeof(Element) * ncount);
584 template<
class Element>
587 return (this->_void_ptr);
595 template<
class Element>
606 template<
class Element>
609 return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->
get_ref_count();
617 template<
class Element>
620 if ((this->_void_ptr) == NULL) {
623 ((To *)(this->_void_ptr))->
ref();
631 template<
class Element>
634 nassertr((this->_void_ptr) != NULL,
true);
635 return ((To *)(this->_void_ptr))->unref();
643 template<
class Element>
646 return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->
get_node_ref_count();
654 template<
class Element>
657 if ((this->_void_ptr) == NULL) {
660 ((To *)(this->_void_ptr))->
node_ref();
668 template<
class Element>
671 nassertr((this->_void_ptr) != NULL,
true);
672 return ((To *)(this->_void_ptr))->node_unref();
680 template<
class Element>
692 template<
class Element>
695 _type_handle = copy._type_handle;
700 #ifdef USE_MOVE_SEMANTICS 706 template<
class Element>
709 _type_handle = from._type_handle;
713 #endif // USE_MOVE_SEMANTICS 722 template<
class Element>
735 template<
class Element>
739 _type_handle(type_handle)
748 template<
class Element>
752 _type_handle(copy._type_handle)
761 template<
class Element>
765 _type_handle(copy._type_handle)
769 #ifdef USE_MOVE_SEMANTICS 775 template<
class Element>
779 _type_handle(from._type_handle)
782 #endif // USE_MOVE_SEMANTICS 784 #ifdef USE_MOVE_SEMANTICS 790 template<
class Element>
794 _type_handle(from._type_handle)
797 #endif // USE_MOVE_SEMANTICS 804 template<
class Element>
807 if ((this->_void_ptr) == NULL) {
808 return _empty_array.begin();
810 return ((To *)(this->_void_ptr))->begin();
818 template<
class Element>
821 if ((this->_void_ptr) == NULL) {
822 return _empty_array.begin();
824 return ((To *)(this->_void_ptr))->end();
832 template<
class Element>
835 if ((this->_void_ptr) == NULL) {
836 return _empty_array.rbegin();
838 return ((To *)(this->_void_ptr))->rbegin();
846 template<
class Element>
849 if ((this->_void_ptr) == NULL) {
850 return _empty_array.rbegin();
852 return ((To *)(this->_void_ptr))->rend();
860 template<
class Element>
863 return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->size();
871 template<
class Element>
874 nassertd((this->_void_ptr) != NULL) {
877 return ((To *)(this->_void_ptr))->max_size();
885 template<
class Element>
888 return ((this->_void_ptr) == NULL) ? true : ((To *)(this->_void_ptr))->empty();
896 template<
class Element>
899 nassertd((this->_void_ptr) != NULL) {
902 return ((To *)(this->_void_ptr))->capacity();
910 template<
class Element>
913 nassertd((this->_void_ptr) != NULL) {
916 nassertd(!((To *)(this->_void_ptr))->empty()) {
917 ((To *)(this->_void_ptr))->push_back(Element());
919 return ((To *)(this->_void_ptr))->front();
927 template<
class Element>
930 nassertd((this->_void_ptr) != NULL) {
933 nassertd(!((To *)(this->_void_ptr))->empty()) {
934 ((To *)(this->_void_ptr))->push_back(Element());
936 return ((To *)(this->_void_ptr))->back();
939 #if !defined(WIN32_VC) && !defined(WIN64_VC) 945 template<
class Element>
948 nassertd((this->_void_ptr) != NULL) {
951 nassertd(!((To *)(this->_void_ptr))->empty()) {
952 ((To *)(this->_void_ptr))->push_back(Element());
954 nassertr(n < ((To *)(this->_void_ptr))->size(), ((To *)(this->_void_ptr))->
operator[](0));
955 return ((To *)(this->_void_ptr))->operator[](n);
963 template<
class Element>
966 return operator[]((size_type)n);
979 template<
class Element>
981 operator
const Element *()
const {
982 const To *vec = (
const To *)(this->_void_ptr);
983 return ((vec == NULL)||(vec->empty())) ? (
const Element *)NULL : &(vec->front());
993 template<
class Element>
996 const To *vec = (
const To *)(this->_void_ptr);
997 return ((vec == NULL)||(vec->empty())) ? (
const Element *)NULL : &(vec->front());
1006 template<
class Element>
1009 nassertd((this->_void_ptr) != NULL) {
1012 return *(
const To *)(this->_void_ptr);
1021 template<
class Element>
1024 return (
const To *)(this->_void_ptr);
1033 template<
class Element>
1037 non_const = (To *)(this->_void_ptr);
1050 template<
class Element>
1066 template<
class Element>
1083 template<
class Element>
1087 count = max(count, n);
1088 count = min(count, size() - n);
1089 return string((
const char *)(
p() + n),
sizeof(Element) * count);
1097 template<
class Element>
1100 return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->
get_ref_count();
1108 template<
class Element>
1111 if ((this->_void_ptr) == NULL) {
1114 ((To *)(this->_void_ptr))->
ref();
1122 template<
class Element>
1125 nassertr((this->_void_ptr) != NULL,
true);
1126 return ((To *)(this->_void_ptr))->unref();
1134 template<
class Element>
1137 return ((this->_void_ptr) == NULL) ? 0 : ((To *)(this->_void_ptr))->
get_node_ref_count();
1145 template<
class Element>
1148 if ((this->_void_ptr) == NULL) {
1151 ((To *)(this->_void_ptr))->
node_ref();
1159 template<
class Element>
1162 nassertr((this->_void_ptr) != NULL,
true);
1163 return ((To *)(this->_void_ptr))->node_unref();
1171 template<
class Element>
1183 template<
class Element>
1186 _type_handle = copy._type_handle;
1196 template<
class Element>
1199 _type_handle = copy._type_handle;
1204 #ifdef USE_MOVE_SEMANTICS 1210 template<
class Element>
1213 _type_handle = from._type_handle;
1217 #endif // USE_MOVE_SEMANTICS 1219 #ifdef USE_MOVE_SEMANTICS 1225 template<
class Element>
1228 _type_handle = from._type_handle;
1232 #endif // USE_MOVE_SEMANTICS 1241 template<
class Element>
Element * p() const
Function p() is similar to the function from PointerTo.
string get_data() const
This method exists mainly to access the data of the array easily from a high-level language such as P...
int get_node_ref_count() const
Returns the node_ref of the underlying vector.
void clear()
To empty the PTA, use the clear() method, since assignment to NULL is problematic (given the ambiguit...
void node_ref() const
Increments the node_ref of the underlying vector.
void * get_void_ptr() const
Returns the reference to memory where the vector is stored.
int get_ref_count() const
Returns 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 ...
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 ...
bool node_unref() const
Decrements the node_ref of the underlying vector.
A special kind of PointerTo that stores an array of the indicated element type, instead of a single e...
static PointerToArray< Element > empty_array(size_type n, TypeHandle type_handle=get_type_handle(Element))
Return an empty array of size n.
ReferenceCountedVector< Element > * v0() const
To access the internal ReferenceCountedVector object, for very low-level fiddling.
void make_empty()
Empties the array pointed to.
void set_void_ptr(void *p)
Sets this PTA to point to the pointer passed in.
void set_data(const string &data)
This method exists mainly to access the data of the array easily from a high-level language such as P...
void ref() const
Increments the reference count of the underlying vector.
PointerToArray< Element > cast_non_const() const
Casts away the constness of the CPTA(Element), and returns an equivalent PTA(Element).
const pvector< Element > & v() const
To access the vector itself, for more direct fiddling with some of the vector's esoteric functionalit...
const Element * p() const
Function p() is similar to the function from ConstPointerTo.
pvector< Element > & v() const
To access the vector itself, for more direct fiddling with some of the vector's esoteric functionalit...
void node_ref() const
Increments the node_ref of the underlying vector.
bool unref() const
Decrements the reference count of the underlying vector.
This is the base class for PointerToArray and ConstPointerToArray.
void set_subdata(size_type n, size_type count, const string &data)
This method exists mainly to access the data of the array easily from a high-level language such as P...
void clear()
To empty the PTA, use the clear() method, since assignment to NULL is problematic (given the ambiguit...
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.
string get_data() const
This method exists mainly to access the data of the array easily from a high-level language such as P...
int get_node_ref_count() const
Returns the node_ref of the underlying vector.
const ReferenceCountedVector< Element > * v0() const
To access the internal ReferenceCountedVector object, for very low-level fiddling.
void swap(PointerToVoid &other) NOEXCEPT
Swaps the contents of this PointerTo with the other, without touching the reference counts...
TypeHandle is the identifier used to differentiate C++ class types.
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...
This defines the object that is actually stored and reference-counted internally by a PointerToArray...
void ref() const
Increments the reference count of the underlying vector.
Similar to PointerToArray, except that its contents may not be modified.
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 ...
bool node_unref() const
Decrements the node_ref of the underlying vector.
bool unref() const
Decrements the reference count of the underlying vector.