mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Renamed PointerToArrayElement to ReferenceCountedArray
This commit is contained in:
parent
759767f9ce
commit
a9c791a034
@ -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
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ public:
|
||||
|
||||
// Reassignment is by pointer, not memberwise as with a vector.
|
||||
INLINE PointerToArray<Element> &
|
||||
operator = (PointerToArrayElement<Element> *ptr);
|
||||
operator = (ReferenceCountedVector<Element> *ptr);
|
||||
INLINE PointerToArray<Element> &
|
||||
operator = (const PointerToArray<Element> ©);
|
||||
INLINE void clear();
|
||||
@ -281,7 +281,7 @@ public:
|
||||
|
||||
// Reassignment is by pointer, not memberwise as with a vector.
|
||||
INLINE ConstPointerToArray<Element> &
|
||||
operator = (PointerToArrayElement<Element> *ptr);
|
||||
operator = (ReferenceCountedVector<Element> *ptr);
|
||||
INLINE ConstPointerToArray<Element> &
|
||||
operator = (const PointerToArray<Element> ©);
|
||||
INLINE ConstPointerToArray<Element> &
|
||||
|
@ -18,23 +18,23 @@
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::Constructor
|
||||
// Function: ReferenceCountedVector::Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE PointerToArrayElement<Element>::
|
||||
PointerToArrayElement() {
|
||||
INLINE ReferenceCountedVector<Element>::
|
||||
ReferenceCountedVector() {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::Copy Constructor
|
||||
// Function: ReferenceCountedVector::Copy Constructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE PointerToArrayElement<Element>::
|
||||
PointerToArrayElement(const PointerToArrayElement<Element> ©) :
|
||||
INLINE ReferenceCountedVector<Element>::
|
||||
ReferenceCountedVector(const ReferenceCountedVector<Element> ©) :
|
||||
NodeReferenceCount(copy),
|
||||
pvector<Element>(copy)
|
||||
{
|
||||
@ -44,24 +44,24 @@ PointerToArrayElement(const PointerToArrayElement<Element> ©) :
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::Destructor
|
||||
// Function: ReferenceCountedVector::Destructor
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE PointerToArrayElement<Element>::
|
||||
~PointerToArrayElement() {
|
||||
INLINE ReferenceCountedVector<Element>::
|
||||
~ReferenceCountedVector() {
|
||||
adjust_size(size(), 0);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::get_col
|
||||
// Function: ReferenceCountedVector::get_col
|
||||
// Access: Public
|
||||
// Description: Returns the pointer to the PStatCollector object that
|
||||
// tracks the total allocated size of this buffer.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE PStatCollectorForwardBase *PointerToArrayElement<Element>::
|
||||
INLINE PStatCollectorForwardBase *ReferenceCountedVector<Element>::
|
||||
get_col() const {
|
||||
#ifdef DO_PSTATS
|
||||
return _col;
|
||||
@ -71,13 +71,13 @@ get_col() const {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::set_col
|
||||
// Function: ReferenceCountedVector::set_col
|
||||
// Access: Public
|
||||
// Description: Changes the pointer to the PStatCollector object that
|
||||
// tracks the total allocated size of this buffer.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void PointerToArrayElement<Element>::
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
set_col(PStatCollectorForwardBase *col) {
|
||||
#ifdef DO_PSTATS
|
||||
if (_col != col) {
|
||||
@ -89,97 +89,97 @@ set_col(PStatCollectorForwardBase *col) {
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::size
|
||||
// Function: ReferenceCountedVector::size
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE TYPENAME PointerToArrayElement<Element>::size_type PointerToArrayElement<Element>::
|
||||
INLINE TYPENAME ReferenceCountedVector<Element>::size_type ReferenceCountedVector<Element>::
|
||||
size() const {
|
||||
return pvector<Element>::size();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::insert
|
||||
// Function: ReferenceCountedVector::insert
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE TYPENAME PointerToArrayElement<Element>::iterator PointerToArrayElement<Element>::
|
||||
INLINE TYPENAME ReferenceCountedVector<Element>::iterator ReferenceCountedVector<Element>::
|
||||
insert(iterator position, const Element &x) {
|
||||
adjust_size(0, 1);
|
||||
return pvector<Element>::insert(position, x);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::insert
|
||||
// Function: ReferenceCountedVector::insert
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void PointerToArrayElement<Element>::
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
insert(iterator position, size_type n, const Element &x) {
|
||||
adjust_size(0, n);
|
||||
pvector<Element>::insert(position, n, x);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::erase
|
||||
// Function: ReferenceCountedVector::erase
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void PointerToArrayElement<Element>::
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
erase(iterator position) {
|
||||
adjust_size(1, 0);
|
||||
pvector<Element>::erase(position);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::erase
|
||||
// Function: ReferenceCountedVector::erase
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void PointerToArrayElement<Element>::
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
erase(iterator first, iterator last) {
|
||||
adjust_size(last - first, 0);
|
||||
pvector<Element>::erase(first, last);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::pop_back
|
||||
// Function: ReferenceCountedVector::pop_back
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void PointerToArrayElement<Element>::
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
pop_back() {
|
||||
adjust_size(1, 0);
|
||||
pvector<Element>::pop_back();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::clear
|
||||
// Function: ReferenceCountedVector::clear
|
||||
// Access: Public
|
||||
// Description:
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void PointerToArrayElement<Element>::
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
clear() {
|
||||
adjust_size(size(), 0);
|
||||
pvector<Element>::clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: PointerToArrayElement::adjust_size
|
||||
// Function: ReferenceCountedVector::adjust_size
|
||||
// Access: Private
|
||||
// Description: This internal function is used to update the
|
||||
// connected PStatCollector (if any) with the change in
|
||||
// size.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE void PointerToArrayElement<Element>::
|
||||
INLINE void ReferenceCountedVector<Element>::
|
||||
adjust_size(size_t orig_size, size_t new_size) {
|
||||
#ifdef DO_PSTATS
|
||||
if (_col != (PStatCollectorForwardBase *)NULL) {
|
||||
@ -195,8 +195,8 @@ adjust_size(size_t orig_size, size_t new_size) {
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template<class Element>
|
||||
INLINE PointerToArrayBase<Element>::
|
||||
PointerToArrayBase(PointerToArrayElement<Element> *ptr) :
|
||||
PointerToBase<PointerToArrayElement<Element> >(ptr)
|
||||
PointerToArrayBase(ReferenceCountedVector<Element> *ptr) :
|
||||
PointerToBase<ReferenceCountedVector<Element> >(ptr)
|
||||
{
|
||||
}
|
||||
|
||||
@ -208,7 +208,7 @@ PointerToArrayBase(PointerToArrayElement<Element> *ptr) :
|
||||
template<class Element>
|
||||
INLINE PointerToArrayBase<Element>::
|
||||
PointerToArrayBase(const PointerToArrayBase<Element> ©) :
|
||||
PointerToBase<PointerToArrayElement<Element> >(copy)
|
||||
PointerToBase<ReferenceCountedVector<Element> >(copy)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "memoryBase.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Class : PointerToArrayElement
|
||||
// Class : ReferenceCountedVector
|
||||
// Description : This defines the object that is actually stored and
|
||||
// reference-counted internally by a PointerToArray. It
|
||||
// is basically a NodeReferenceCount-capable STL vector.
|
||||
@ -44,15 +44,15 @@
|
||||
// may not use it.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class Element>
|
||||
class PointerToArrayElement : public NodeReferenceCount, public pvector<Element> {
|
||||
class ReferenceCountedVector : public NodeReferenceCount, public pvector<Element> {
|
||||
public:
|
||||
typedef TYPENAME pvector<Element>::iterator iterator;
|
||||
typedef TYPENAME pvector<Element>::size_type size_type;
|
||||
|
||||
INLINE PointerToArrayElement();
|
||||
INLINE PointerToArrayElement(const PointerToArrayElement<Element> ©);
|
||||
INLINE ~PointerToArrayElement();
|
||||
ALLOC_DELETED_CHAIN(PointerToArrayElement<Element>);
|
||||
INLINE ReferenceCountedVector();
|
||||
INLINE ReferenceCountedVector(const ReferenceCountedVector<Element> ©);
|
||||
INLINE ~ReferenceCountedVector();
|
||||
ALLOC_DELETED_CHAIN(ReferenceCountedVector<Element>);
|
||||
|
||||
INLINE PStatCollectorForwardBase *get_col() const;
|
||||
INLINE void set_col(PStatCollectorForwardBase *col);
|
||||
@ -83,16 +83,16 @@ private:
|
||||
// use either derived class instead.
|
||||
//
|
||||
// This extends PointerToBase to be a pointer to a
|
||||
// PointerToArrayElement, above, which is essentially a
|
||||
// ReferenceCountedVector, above, which is essentially a
|
||||
// reference-counted STL vector.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
template <class Element>
|
||||
class PointerToArrayBase : public PointerToBase<PointerToArrayElement<Element> > {
|
||||
class PointerToArrayBase : public PointerToBase<ReferenceCountedVector<Element> > {
|
||||
public:
|
||||
typedef TYPENAME PointerToBase<PointerToArrayElement<Element> >::To To;
|
||||
typedef TYPENAME PointerToBase<ReferenceCountedVector<Element> >::To To;
|
||||
|
||||
protected:
|
||||
INLINE PointerToArrayBase(PointerToArrayElement<Element> *ptr);
|
||||
INLINE PointerToArrayBase(ReferenceCountedVector<Element> *ptr);
|
||||
INLINE PointerToArrayBase(const PointerToArrayBase<Element> ©);
|
||||
|
||||
PUBLISHED:
|
||||
|
Loading…
x
Reference in New Issue
Block a user