Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File 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 >:

PointerToBase< RefCountObj< pvector< Element > > > List of all members.

Public Types

typedef TYPENAME pvector<
Element >::value_type 
value_type
typedef TYPENAME pvector<
Element >::reference 
reference
typedef TYPENAME pvector<
Element >::const_reference 
const_reference
typedef TYPENAME pvector<
Element >::iterator 
iterator
typedef TYPENAME pvector<
Element >::const_iterator 
const_iterator
typedef TYPENAME pvector<
Element >::reverse_iterator 
reverse_iterator
typedef TYPENAME pvector<
Element >::const_reverse_iterator 
const_reverse_iterator
typedef TYPENAME pvector<
Element >::difference_type 
difference_type
typedef TYPENAME pvector<
Element >::size_type 
size_type
typedef RefCountObj< pvector<
Element > > 
To

Public Member Functions

 PointerToArray ()
 PointerToArray (size_type n, const Element &value)
 PointerToArray (const PointerToArray< Element > &copy)
iterator begin () const
iterator end () const
TYPENAME PointerToArray< Element
>::reverse_iterator 
rbegin () const
TYPENAME PointerToArray< Element
>::reverse_iterator 
rend () const
size_type size () const
size_type max_size () const
bool empty () const
void reserve (size_type n)
size_type capacity () const
reference front () const
reference back () const
iterator insert (iterator position, const Element &x) const
void insert (iterator position, size_type n, const Element &x) const
void erase (iterator position) const
void erase (iterator first, iterator last) const
reference operator[] (size_type n) const
reference operator[] (int n) const
void push_back (const Element &x)
void pop_back ()
void make_empty ()
 Empties the array pointed to.

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

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

pvector< Element > & v () const
 To access the vector itself, for more direct fiddling with some of the vector's esoteric functionality.

void * get_void_ptr () const
 Returns the reference to memory where the vector is stored.

void set_void_ptr (void *p)
 Sets this PTA to point to the pointer passed in.

int get_ref_count () const
 Returns the reference count of the underlying vector.

PointerToArray< Element > & operator= (RefCountObj< pvector< Element > > *ptr)
PointerToArray< Element > & operator= (const PointerToArray< Element > &copy)
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).

bool operator== (const To *other) const
bool operator== (To *other) const
bool operator== (const PointerToBase< To > &other) const
bool operator!= (const To *other) const
bool operator!= (To *other) const
bool operator!= (const PointerToBase< To > &other) const
bool operator> (const To *other) const
bool operator> (To *other) const
bool operator> (const PointerToBase< To > &other) const
bool operator<= (const To *other) const
bool operator<= (To *other) const
bool operator<= (const PointerToBase< To > &other) const
bool operator>= (const To *other) const
bool operator>= (To *other) const
bool operator>= (const PointerToBase< To > &other) const
bool operator< (const To *other) const
bool operator< (const PointerToBase< To > &other) const
bool is_null () const
void output (ostream &out) const

Static Public Member Functions

PointerToArray< Element > empty_array (size_type n)

Protected Member Functions

void reassign (To *ptr)
void reassign (const PointerToBase< To > &copy)

Protected Attributes

To_ptr

Static Private Attributes

pvector< Element > _empty_array

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.

Definition at line 104 of file pointerToArray.h.


Member Typedef Documentation

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

Definition at line 110 of file pointerToArray.h.

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

Definition at line 108 of file pointerToArray.h.

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

Definition at line 112 of file pointerToArray.h.

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

Definition at line 113 of file pointerToArray.h.

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

Definition at line 109 of file pointerToArray.h.

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

Definition at line 107 of file pointerToArray.h.

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

Definition at line 111 of file pointerToArray.h.

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

Definition at line 114 of file pointerToArray.h.

typedef RefCountObj< pvector< Element > > PointerToBase< RefCountObj< pvector< Element > > >::To [inherited]
 

Definition at line 99 of file pointerTo.h.

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

Definition at line 106 of file pointerToArray.h.


Constructor & Destructor Documentation

template<class Element>
PointerToArray< Element >::PointerToArray  )  [inline]
 

Definition at line 37 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, and PointerToArray< Element >::reserve().

template<class Element>
PointerToArray< Element >::PointerToArray size_type  n,
const Element &  value
[inline]
 

Definition at line 61 of file pointerToArray.I.

References INLINE.

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

Definition at line 76 of file pointerToArray.I.

References PointerToArray< Element >::_empty_array, PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, NULL, and TYPENAME.


Member Function Documentation

template<class Element>
TYPENAME PointerToArray< Element >::reference PointerToArray< Element >::back  )  const [inline]
 

Definition at line 245 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, nassertv, NULL, and x.

template<class Element>
TYPENAME PointerToArray< Element >::iterator PointerToArray< Element >::begin  )  const [inline]
 

Definition at line 90 of file pointerToArray.I.

References PointerToArray< Element >::_empty_array, PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, NULL, and TYPENAME.

template<class Element>
TYPENAME PointerToArray< Element >::size_type PointerToArray< Element >::capacity  )  const [inline]
 

Definition at line 212 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, nassertd, NULL, and TYPENAME.

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).

Reimplemented from PointerToBase< RefCountObj< pvector< Element > > >.

Definition at line 559 of file pointerToArray.I.

References PointerToArray< Element >::_empty_array, PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, NULL, and TYPENAME.

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

Definition at line 183 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, nassertr, NULL, and TYPENAME.

template<class Element>
PointerToArray< Element > PointerToArray< Element >::empty_array size_type  n  )  [inline, static]
 

Definition at line 45 of file pointerToArray.I.

template<class Element>
TYPENAME PointerToArray< Element >::iterator PointerToArray< Element >::end  )  const [inline]
 

Definition at line 106 of file pointerToArray.I.

References PointerToArray< Element >::_empty_array, PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, NULL, and TYPENAME.

template<class Element>
void PointerToArray< Element >::erase iterator  first,
iterator  last
const [inline]
 

Definition at line 314 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, NULL, PointerToBase< RefCountObj< pvector< Element > > >::reassign(), and x.

template<class Element>
void PointerToArray< Element >::erase iterator  position  )  const [inline]
 

Definition at line 296 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr.

template<class Element>
TYPENAME PointerToArray< Element >::reference PointerToArray< Element >::front  )  const [inline]
 

Definition at line 226 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, nassertr, NULL, TYPENAME, and x.

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

Returns the reference count of the underlying vector.

Definition at line 513 of file pointerToArray.I.

References PointerToArray< Element >::_empty_array, PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, NULL, and TYPENAME.

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 get_void_ptr

Definition at line 484 of file pointerToArray.I.

References INLINE, and NULL.

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

Definition at line 280 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr.

template<class Element>
TYPENAME PointerToArray< Element >::iterator PointerToArray< Element >::insert iterator  position,
const Element &  x
const [inline]
 

Definition at line 264 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr.

bool PointerToBase< RefCountObj< pvector< Element > > >::is_null  )  const [inline, inherited]
 

Returns true if the PointerTo is a NULL pointer, false otherwise.

(Direct comparison to a NULL pointer also works.)

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 405 of file pointerToArray.I.

References INLINE.

template<class Element>
TYPENAME PointerToArray< Element >::size_type PointerToArray< Element >::max_size  )  const [inline]
 

Definition at line 167 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, NULL, and PointerToBase< RefCountObj< pvector< Element > > >::reassign().

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 431 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, and NULL.

bool PointerToBase< RefCountObj< pvector< Element > > >::operator!= const PointerToBase< To > &  other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator!= To other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator!= const To other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator< const PointerToBase< To > &  other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator< const To other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator<= const PointerToBase< To > &  other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator<= To other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator<= const To other  )  const [inline, inherited]
 

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

Definition at line 540 of file pointerToArray.I.

template<class Element>
PointerToArray< Element > & PointerToArray< Element >::operator= RefCountObj< pvector< Element > > *  ptr  )  [inline]
 

Definition at line 526 of file pointerToArray.I.

bool PointerToBase< RefCountObj< pvector< Element > > >::operator== const PointerToBase< To > &  other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator== To other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator== const To other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator> const PointerToBase< To > &  other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator> To other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator> const To other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator>= const PointerToBase< To > &  other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator>= To other  )  const [inline, inherited]
 

bool PointerToBase< RefCountObj< pvector< Element > > >::operator>= const To other  )  const [inline, inherited]
 

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

Definition at line 353 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, nassertd, nassertv, and NULL.

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

Definition at line 333 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, nassertd, nassertv, and NULL.

void PointerToBase< RefCountObj< pvector< Element > > >::output ostream &  out  )  const [inherited]
 

A handy function to output PointerTo's as a hex pointer followed by a reference count.

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 449 of file pointerToArray.I.

template<class Element>
void PointerToArray< Element >::pop_back  )  [inline]
 

Definition at line 383 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, and NULL.

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

Definition at line 367 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, and NULL.

template<class Element>
TYPENAME PointerToArray< Element >::reverse_iterator PointerToArray< Element >::rbegin  )  const [inline]
 

Definition at line 122 of file pointerToArray.I.

References PointerToArray< Element >::_empty_array, PointerToBase< RefCountObj< pvector< Element > > >::_ptr, and NULL.

void PointerToBase< RefCountObj< pvector< Element > > >::reassign const PointerToBase< To > &  copy  )  [inline, protected, inherited]
 

void PointerToBase< RefCountObj< pvector< Element > > >::reassign To ptr  )  [protected, inherited]
 

This is the main work of the PointerTo family.

When the pointer is reassigned, decrement the old reference count and increment the new one.

Referenced by PointerToArray< Element >::erase(), PointerToArray< Element >::max_size(), ConstPointerToArray< Element >::operator[](), and PointerToArray< Element >::v().

template<class Element>
TYPENAME PointerToArray< Element >::reverse_iterator PointerToArray< Element >::rend  )  const [inline]
 

Definition at line 138 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, nassertd, NULL, and TYPENAME.

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

Referenced by PointerToArray< Element >::PointerToArray().

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 499 of file pointerToArray.I.

template<class Element>
TYPENAME PointerToArray< Element >::size_type PointerToArray< Element >::size  )  const [inline]
 

Definition at line 154 of file pointerToArray.I.

References PointerToBase< RefCountObj< pvector< Element > > >::_ptr, INLINE, and NULL.

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 465 of file pointerToArray.I.

References INLINE, NULL, and PointerToBase< RefCountObj< pvector< Element > > >::reassign().


Member Data Documentation

template<class Element>
pvector< Element > PointerToArray< Element >::_empty_array [static, private]
 

Definition at line 23 of file pointerToArray.I.

Referenced by PointerToArray< Element >::begin(), PointerToArray< Element >::clear(), PointerToArray< Element >::end(), PointerToArray< Element >::get_ref_count(), PointerToArray< Element >::PointerToArray(), and PointerToArray< Element >::rbegin().

To* PointerToBase< RefCountObj< pvector< Element > > >::_ptr [protected, inherited]
 

Definition at line 110 of file pointerTo.h.

Referenced by PointerToArray< Element >::back(), PointerToArray< Element >::begin(), PointerToArray< Element >::capacity(), PointerToArray< Element >::clear(), ConstPointerToArray< Element >::ConstPointerToArray(), ConstPointerToArray< Element >::empty(), PointerToArray< Element >::empty(), ConstPointerToArray< Element >::end(), PointerToArray< Element >::end(), PointerToArray< Element >::erase(), PointerToArray< Element >::front(), PointerToArray< Element >::get_ref_count(), PointerToArray< Element >::insert(), ConstPointerToArray< Element >::max_size(), PointerToArray< Element >::max_size(), PointerToArray< Element >::operator Element *(), PointerToArray< Element >::operator[](), PointerToArray< Element >::PointerToArray(), PointerToArray< Element >::pop_back(), PointerToArray< Element >::push_back(), PointerToArray< Element >::rbegin(), PointerToArray< Element >::rend(), ConstPointerToArray< Element >::size(), and PointerToArray< Element >::size().


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:54:13 2003 for Panda by doxygen1.3