Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ResizeArray Class Template Reference

A template class which implements a dynamically-growing, automatically resizing array of data of a given type. Elements in the array may be accessed via the [] operator. When new data is added to the end of an array, the size of the array is automatically increased if necessary. XXX Do not parametrize this class with a datatype which cannot be shallow-copied! This class uses memcpy to resize, and therefore classes which contain dynamically-allocated memory blocks will crash and burn if the ResizeArray ever gets resized. More...

#include <ResizeArray.h>

List of all members.

Public Methods

 ResizeArray (int s=3)
 Constructor The first argument is the initial internal size of the array, i.e. the initial number of elements for which to allocate memory (although the initial external size of the array will be zero). More...

 ~ResizeArray ()
int num (void) const
 current size of array. More...

T & operator[] (int N)
 unchecked accessor, for speed. More...

T const & operator[] (int N) const
 a const version of above. More...

void append (const T &val)
 add a new element to the end of the array. Return index of new item. More...

void remove (int n)
 remove an item from the array, shifting remaining items down by 1. More...

void clear ()
 delete entire array by defining size to be empty. More...

void truncatelastn (int N)
 truncate the array by defining the size to be N items less. More...

int find (const T &val)
 scan the array until the first item that matches in the array is found. Return the index if found, (-1) otherwise. More...


Detailed Description

template<class T>
class ResizeArray< T >

A template class which implements a dynamically-growing, automatically resizing array of data of a given type. Elements in the array may be accessed via the [] operator. When new data is added to the end of an array, the size of the array is automatically increased if necessary. XXX Do not parametrize this class with a datatype which cannot be shallow-copied! This class uses memcpy to resize, and therefore classes which contain dynamically-allocated memory blocks will crash and burn if the ResizeArray ever gets resized.

Definition at line 36 of file ResizeArray.h.


Constructor & Destructor Documentation

template<class T>
ResizeArray< T >::ResizeArray int    s = 3 [inline]
 

Constructor The first argument is the initial internal size of the array, i.e. the initial number of elements for which to allocate memory (although the initial external size of the array will be zero).

Definition at line 50 of file ResizeArray.h.

template<class T>
ResizeArray< T >::~ResizeArray   [inline]
 

Definition at line 56 of file ResizeArray.h.


Member Function Documentation

template<class T>
void ResizeArray< T >::append const T &    val [inline]
 

add a new element to the end of the array. Return index of new item.

Definition at line 65 of file ResizeArray.h.

Referenced by Residue::add_atom, GeometryList::add_geometry, NameList< Material * >::add_name, SmallRingLinkages::addLinkagePath, LinkageEdge::addPath, SmallRing::append, Fragment::append, bondsearchthread, GeometryMol::calculate_all, GraphicsFltkRepVolumetric::dataset_append, DisplayDevice::find_pbc_cells, DisplayDevice::find_pbc_images, generic_get_names, Molecule::get_new_frames, SmallRingLinkages::getLinkageEdge, measure_energy, measure_geom, measure_pbc_neighbors, measure_sasa, mol_delete_cb, parse_frames, Molecule::record_database, Molecule::record_file, Molecule::record_remarks, SmallRing::reverse, text_cmd_animate, VMDGetOptions, VMDinitialize, write_stride_record, and MolFilePlugin::write_structure.

template<class T>
void ResizeArray< T >::clear void    [inline]
 

delete entire array by defining size to be empty.

Definition at line 97 of file ResizeArray.h.

Referenced by SmallRingLinkages::clear, SmallRing::clear, GraphicsFltkRepVolumetric::dataset_clear, measure_pbc_neighbors, SmallRing::reverse, and write_stride_record.

template<class T>
int ResizeArray< T >::find const T &    val [inline]
 

scan the array until the first item that matches in the array is found. Return the index if found, (-1) otherwise.

Definition at line 110 of file ResizeArray.h.

template<class T>
int ResizeArray< T >::num void    const [inline]
 

current size of array.

Definition at line 60 of file ResizeArray.h.

Referenced by GeometryList::add_geometry, DrawMolecule::components, VolMapCreateFastEnergy::compute_frame, DrawMolecule::current, GraphicsFltkRepVolumetric::dataset_append, GeometryList::del_geometry, GeometryList::do_color_changed, BaseMolecule::find_atom_in_residue, DisplayDevice::find_pbc_images, generic_get_names, Molecule::get_accession, Molecule::get_database, Molecule::get_file, Molecule::get_file_specs, DrawMolecule::get_frame, DrawMolecule::get_last_frame, Molecule::get_new_frames, Molecule::get_remarks, Molecule::get_type, SmallRingLinkages::getLinkageEdge, GeometryList::getTextFormat, GeometryList::getTextOffset, getvalues, label_delete, label_getvalues, label_hide, label_show, SmallRing::last_atom, listall, measure_pbc_neighbors, measure_sasa, mol_delete_cb, SmallRing::num, MoleculeList::num, Fragment::num, Scene::num_colorscale_methods, MoleculeGraphics::num_elements, Molecule::num_files, Symmetry::numaxes, DrawMolecule::numframes, Symmetry::numplanes, Symmetry::numrotreflect, DisplayDevice::pick, GeometryList::prepare, read_stride_record, PSDisplayDevice::render, OpenGLRenderer::render, FileRenderer::render, ToolFltkMenu::reset_device_menus, SmallRing::reverse, sasa, GeometryList::setTextFormat, GeometryList::setTextOffset, GeometryList::setTextSize, GeometryList::show_geometry, Buttons::start, Buttons::state, text_cmd_animate, text_cmd_label, OpenGLRenderer::update_lists, vmd_measure_angle, vmd_measure_bond, vmd_measure_dihed, vmd_measure_energy, vmd_measure_pbc_neighbors, vmd_measure_sasa, VMDinitialize, VMDreadStartup, write_stride_record, and MolFilePlugin::write_structure.

template<class T>
T const& ResizeArray< T >::operator[] int    N const [inline]
 

a const version of above.

Definition at line 62 of file ResizeArray.h.

template<class T>
T& ResizeArray< T >::operator[] int    N [inline]
 

unchecked accessor, for speed.

Definition at line 61 of file ResizeArray.h.

template<class T>
void ResizeArray< T >::remove int    n [inline]
 

remove an item from the array, shifting remaining items down by 1.

Definition at line 89 of file ResizeArray.h.

Referenced by GeometryList::del_geometry.

template<class T>
void ResizeArray< T >::truncatelastn int    N [inline]
 

truncate the array by defining the size to be N items less.

Definition at line 102 of file ResizeArray.h.

Referenced by SmallRing::remove_last.


The documentation for this class was generated from the following file:
Generated on Sun Jul 6 01:28:38 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002