|
|
@@ -30,7 +30,7 @@ pvector<Element> ConstPointerToArray<Element>::_empty_array;
|
|
|
template<class Element>
|
|
|
INLINE PointerToArray<Element>::
|
|
|
PointerToArray() :
|
|
|
- PointerToArrayBase<Element>((PointerToArrayElement<Element> *)NULL)
|
|
|
+ PointerToArrayBase<Element>((ReferenceCountedVector<Element> *)NULL)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -56,7 +56,7 @@ PointerToArray<Element>::empty_array(size_type n) {
|
|
|
template<class Element>
|
|
|
INLINE PointerToArray<Element>::
|
|
|
PointerToArray(size_type n, const Element &value) :
|
|
|
- PointerToArrayBase<Element>(new PointerToArrayElement<Element>) {
|
|
|
+ PointerToArrayBase<Element>(new ReferenceCountedVector<Element>) {
|
|
|
((To *)(this->_void_ptr))->reserve(n);
|
|
|
insert(begin(), n, value);
|
|
|
}
|
|
|
@@ -101,7 +101,7 @@ INLINE void PointerToArray<Element>::
|
|
|
set_col(PStatCollectorForwardBase *col) {
|
|
|
#ifdef DO_PSTATS
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new PointerToArrayElement<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->set_col(col);
|
|
|
#endif // DO_PSTATS
|
|
|
@@ -183,7 +183,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::size_type PointerToArray<Element>::
|
|
|
max_size() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
return ((To *)(this->_void_ptr))->max_size();
|
|
|
}
|
|
|
@@ -208,7 +208,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
reserve(TYPENAME PointerToArray<Element>::size_type n) {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new PointerToArrayElement<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->reserve(n);
|
|
|
}
|
|
|
@@ -234,7 +234,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::reference PointerToArray<Element>::
|
|
|
front() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -251,7 +251,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::reference PointerToArray<Element>::
|
|
|
back() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -268,7 +268,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::iterator PointerToArray<Element>::
|
|
|
insert(iterator position, const Element &x) {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new PointerToArrayElement<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>);
|
|
|
position = end();
|
|
|
}
|
|
|
nassertr(position >= ((To *)(this->_void_ptr))->begin() &&
|
|
|
@@ -285,7 +285,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
insert(iterator position, size_type n, const Element &x) {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new PointerToArrayElement<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>);
|
|
|
position = end();
|
|
|
}
|
|
|
nassertv(position >= ((To *)(this->_void_ptr))->begin() &&
|
|
|
@@ -331,7 +331,7 @@ template<class Element>
|
|
|
INLINE TYPENAME PointerToArray<Element>::reference PointerToArray<Element>::
|
|
|
operator [](size_type n) const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -392,7 +392,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
push_back(const Element &x) {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- reassign(new PointerToArrayElement<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->push_back(x);
|
|
|
}
|
|
|
@@ -406,7 +406,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
pop_back() {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
nassertv(!((To *)(this->_void_ptr))->empty());
|
|
|
((To *)(this->_void_ptr))->pop_back();
|
|
|
@@ -423,7 +423,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
make_empty() {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
nassertv(!((To *)(this->_void_ptr))->empty());
|
|
|
((To *)(this->_void_ptr))->clear();
|
|
|
@@ -441,7 +441,8 @@ make_empty() {
|
|
|
template<class Element>
|
|
|
INLINE PointerToArray<Element>::
|
|
|
operator Element *() const {
|
|
|
- return ((this->_void_ptr) == NULL) ? (Element *)NULL : &(((To *)(this->_void_ptr))->front());
|
|
|
+ To *vec = (To *)(this->_void_ptr);
|
|
|
+ return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front());
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -454,7 +455,8 @@ operator Element *() const {
|
|
|
template<class Element>
|
|
|
INLINE Element *PointerToArray<Element>::
|
|
|
p() const {
|
|
|
- return ((this->_void_ptr) == NULL) ? (Element *)NULL : &(((To *)(this->_void_ptr))->front());
|
|
|
+ To *vec = (To *)(this->_void_ptr);
|
|
|
+ return ((vec == NULL)||(vec->empty())) ? (Element *)NULL : &(vec->front());
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -467,7 +469,7 @@ template<class Element>
|
|
|
INLINE pvector<Element> &PointerToArray<Element>::
|
|
|
v() const {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
return *((To *)(this->_void_ptr));
|
|
|
}
|
|
|
@@ -526,7 +528,7 @@ template<class Element>
|
|
|
INLINE void PointerToArray<Element>::
|
|
|
node_ref() const {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- ((PointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((PointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->node_ref();
|
|
|
}
|
|
|
@@ -550,7 +552,7 @@ node_unref() const {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class Element>
|
|
|
INLINE PointerToArray<Element> &PointerToArray<Element>::
|
|
|
-operator = (PointerToArrayElement<Element> *ptr) {
|
|
|
+operator = (ReferenceCountedVector<Element> *ptr) {
|
|
|
reassign(ptr);
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -582,14 +584,14 @@ clear() {
|
|
|
PT(PStatCollectorForwardBase) col = ((To *)(this->_void_ptr))->get_col();
|
|
|
if (col != (PStatCollectorForwardBase *)NULL) {
|
|
|
// If we have a PStat counter, preserve it.
|
|
|
- reassign(new PointerToArrayElement<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>);
|
|
|
((To *)(this->_void_ptr))->set_col(col);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
#endif // DO_PSTATS
|
|
|
|
|
|
- reassign((PointerToArrayElement<Element> *)NULL);
|
|
|
+ reassign((ReferenceCountedVector<Element> *)NULL);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -602,7 +604,7 @@ clear() {
|
|
|
template<class Element>
|
|
|
INLINE ConstPointerToArray<Element>::
|
|
|
ConstPointerToArray() :
|
|
|
- PointerToArrayBase<Element>((PointerToArrayElement<Element> *)NULL)
|
|
|
+ PointerToArrayBase<Element>((ReferenceCountedVector<Element> *)NULL)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
@@ -723,7 +725,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::size_type ConstPointerToArray<Element>::
|
|
|
max_size() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
return ((To *)(this->_void_ptr))->max_size();
|
|
|
}
|
|
|
@@ -748,7 +750,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::size_type ConstPointerToArray<Element>::
|
|
|
capacity() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
return ((To *)(this->_void_ptr))->capacity();
|
|
|
}
|
|
|
@@ -762,7 +764,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
|
|
|
front() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -779,7 +781,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
|
|
|
back() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -797,7 +799,7 @@ template<class Element>
|
|
|
INLINE TYPENAME ConstPointerToArray<Element>::reference ConstPointerToArray<Element>::
|
|
|
operator [](size_type n) const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
nassertd(!((To *)(this->_void_ptr))->empty()) {
|
|
|
((To *)(this->_void_ptr))->push_back(Element());
|
|
|
@@ -845,7 +847,8 @@ get_element(size_type n) const {
|
|
|
template<class Element>
|
|
|
INLINE ConstPointerToArray<Element>::
|
|
|
operator const Element *() const {
|
|
|
- return ((this->_void_ptr) == NULL) ? (const Element *)NULL : &(((To *)(this->_void_ptr))->front());
|
|
|
+ To *vec = (To *)(this->_void_ptr);
|
|
|
+ return ((vec == NULL)||(vec->empty())) ? (const Element *)NULL : &(vec->front());
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -858,7 +861,8 @@ operator const Element *() const {
|
|
|
template<class Element>
|
|
|
INLINE const Element *ConstPointerToArray<Element>::
|
|
|
p() const {
|
|
|
- return ((this->_void_ptr) == NULL) ? (const Element *)NULL : &(((To *)(this->_void_ptr))->front());
|
|
|
+ To *vec = (To *)(this->_void_ptr);
|
|
|
+ return ((vec == NULL)||(vec->empty())) ? (const Element *)NULL : &(vec->front());
|
|
|
}
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
@@ -871,7 +875,7 @@ template<class Element>
|
|
|
INLINE const pvector<Element> &ConstPointerToArray<Element>::
|
|
|
v() const {
|
|
|
nassertd((this->_void_ptr) != NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
return *(To *)(this->_void_ptr);
|
|
|
}
|
|
|
@@ -907,7 +911,7 @@ template<class Element>
|
|
|
INLINE void ConstPointerToArray<Element>::
|
|
|
node_ref() const {
|
|
|
if ((this->_void_ptr) == NULL) {
|
|
|
- ((ConstPointerToArray<Element> *)this)->reassign(new PointerToArrayElement<Element>);
|
|
|
+ ((ConstPointerToArray<Element> *)this)->reassign(new ReferenceCountedVector<Element>);
|
|
|
}
|
|
|
((To *)(this->_void_ptr))->node_ref();
|
|
|
}
|
|
|
@@ -931,7 +935,7 @@ node_unref() const {
|
|
|
////////////////////////////////////////////////////////////////////
|
|
|
template<class Element>
|
|
|
INLINE ConstPointerToArray<Element> &ConstPointerToArray<Element>::
|
|
|
-operator = (PointerToArrayElement<Element> *ptr) {
|
|
|
+operator = (ReferenceCountedVector<Element> *ptr) {
|
|
|
reassign(ptr);
|
|
|
return *this;
|
|
|
}
|
|
|
@@ -975,14 +979,14 @@ clear() {
|
|
|
PT(PStatCollectorForwardBase) col = ((To *)(this->_void_ptr))->get_col();
|
|
|
if (col != (PStatCollectorForwardBase *)NULL) {
|
|
|
// If we have a PStat counter, preserve it.
|
|
|
- reassign(new PointerToArrayElement<Element>);
|
|
|
+ reassign(new ReferenceCountedVector<Element>);
|
|
|
((To *)(this->_void_ptr))->set_col(col);
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#else // DO_PSTATS
|
|
|
- reassign((PointerToArrayElement<Element> *)NULL);
|
|
|
+ reassign((ReferenceCountedVector<Element> *)NULL);
|
|
|
#endif // DO_PSTATS
|
|
|
}
|
|
|
|