Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members 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 (ptrdiff_t s=3L)
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 ()
ptrdiff_t num (void) const
current size of array. More...

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

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

void set_size (ptrdiff_t N)
Set "occupied" array size to N elements -- Expert use only. More...

void extend (ptrdiff_t addN)
resize array to accomodate up to addN new elements -- Expert use only. More...

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

void append2 (const T &vala, const T &valb)
add two new elements to the end of the array, e.g. angles. More...

void append3 (const T &vala, const T &valb, const T &valc)
add three new elements to the end of the array, e.g. angles. More...

void append4 (const T &vala, const T &valb, const T &valc, const T &vald)
add four new elements to the end of the array, e.g. dihedrals/impropers. More...

void appendN (const T &val, ptrdiff_t addN)
add N elements to the end of the array. More...

void append3 (const T *vals)
add three new elements, e.g. vertex/normal/color to the end of the array. More...

void append2x3 (const T *valsa, const T *valsb)
add two groups of three new elements to the end of the array. More...

void append3x3 (const T *valsa, const T *valsb, const T *valsc)
add three groups of three new elements to the end of the array. More...

void append9 (const T *vals)
add nine new elements, e.g. v0+v1+v2, vertex+normal+color, to the end of the array. More...

void appendlist (const T *vals, ptrdiff_t addN)
add N elements to the end of the array. More...

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

T & pop ()
remove the last item from the array, unchecked for speed. More...

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

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

ptrdiff_t 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 41 of file ResizeArray.h.


Constructor & Destructor Documentation

template<class T>
ResizeArray< T >::ResizeArray ( ptrdiff_t s = 3L ) [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 56 of file ResizeArray.h.

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

Definition at line 62 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.

Definition at line 102 of file ResizeArray.h.

Referenced by Residue::add_atom, BaseMolecule::add_cterm, GeometryList::add_geometry, BaseMolecule::add_instance, NameList< Material * >::add_name, SmallRingLinkages::addLinkagePath, LinkageEdge::addPath, SmallRing::append, Fragment::append, bondsearchthread, QuickSurf::calc_surf, GeometryMol::calculate_all, GraphicsFltkRepOrbital::dataset_append, GraphicsFltkRepVolumetric::dataset_append, ColorscaleLumaChart::draw, DisplayDevice::find_instance_images, DisplayDevice::find_pbc_images, generic_get_names, Molecule::get_new_frames, SmallRingLinkages::getLinkageEdge, measure_energy, measure_geom, measure_pbc_neighbors, measure_sasa, measure_sasa_perresidue, measure_sasa_thread, mol_delete_cb, parse_frames, Molecule::record_database, Molecule::record_file, Molecule::record_remarks, SmallRing::reverse, X3DOMDisplayDevice::text, X3DDisplayDevice::text, text_cmd_animate, VMDGetOptions, VMDinitialize, write_ss_input_pdb, and MolFilePlugin::write_structure.

template<class T>
void ResizeArray< T >::append2 ( const T & vala,
const T & valb
) [inline]

add two new elements to the end of the array, e.g. angles.

Definition at line 135 of file ResizeArray.h.

template<class T>
void ResizeArray< T >::append2x3 ( const T * valsa,
const T * valsb
) [inline]

add two groups of three new elements to the end of the array.

Definition at line 180 of file ResizeArray.h.

Referenced by OSPRayDisplayDevice::text, OSPRay2DisplayDevice::text, and OptiXDisplayDevice::text.

template<class T>
void ResizeArray< T >::append3 ( const T * vals ) [inline]

add three new elements, e.g. vertex/normal/color to the end of the array.

Definition at line 171 of file ResizeArray.h.

template<class T>
void ResizeArray< T >::append3 ( const T & vala,
const T & valb,
const T & valc
) [inline]

add three new elements to the end of the array, e.g. angles.

Definition at line 143 of file ResizeArray.h.

Referenced by QuickSurf::calc_surf, DisplayDevice::find_pbc_cells, Molecule::get_new_frames, measure_pbc_neighbors, measure_sasa, measure_sasa_perresidue, X3DOMDisplayDevice::text, X3DDisplayDevice::text, OSPRayDisplayDevice::text, OSPRay2DisplayDevice::text, OptiXDisplayDevice::text, and MolFilePlugin::write_structure.

template<class T>
void ResizeArray< T >::append3x3 ( const T * valsa,
const T * valsb,
const T * valsc
) [inline]

add three groups of three new elements to the end of the array.

Definition at line 193 of file ResizeArray.h.

template<class T>
void ResizeArray< T >::append4 ( const T & vala,
const T & valb,
const T & valc,
const T & vald
) [inline]

add four new elements to the end of the array, e.g. dihedrals/impropers.

Definition at line 152 of file ResizeArray.h.

Referenced by MolFilePlugin::write_structure.

template<class T>
void ResizeArray< T >::append9 ( const T * vals ) [inline]

add nine new elements, e.g. v0+v1+v2, vertex+normal+color, to the end of the array.

Definition at line 211 of file ResizeArray.h.

template<class T>
void ResizeArray< T >::appendlist ( const T * vals,
ptrdiff_t addN
) [inline]

add N elements to the end of the array.

Definition at line 226 of file ResizeArray.h.

template<class T>
void ResizeArray< T >::appendN ( const T & val,
ptrdiff_t addN
) [inline]

add N elements to the end of the array.

Definition at line 162 of file ResizeArray.h.

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

delete entire array by defining size to be empty.

Definition at line 249 of file ResizeArray.h.

Referenced by SmallRingLinkages::clear, SmallRing::clear, NameList< Material * >::clear, OSPRayRenderer::clear_all_lights, OSPRay2Renderer::clear_all_lights, OptiXRenderer::clear_all_lights, ANARIRender::clear_all_lights, BaseMolecule::clear_angles, BaseMolecule::clear_cterms, BaseMolecule::clear_dihedrals, BaseMolecule::clear_impropers, BaseMolecule::clear_instances, GraphicsFltkRepOrbital::dataset_clear, GraphicsFltkRepVolumetric::dataset_clear, ColorscaleLumaChart::draw, measure_pbc_neighbors, SmallRing::reverse, X3DOMDisplayDevice::text, X3DDisplayDevice::text, and write_ss_input_pdb.

template<class T>
void ResizeArray< T >::extend ( ptrdiff_t addN ) [inline]

resize array to accomodate up to addN new elements -- Expert use only.

Definition at line 81 of file ResizeArray.h.

Referenced by ResizeArray< ShapeClass >::append, ResizeArray< ShapeClass >::append2, ResizeArray< ShapeClass >::append2x3, ResizeArray< ShapeClass >::append3, ResizeArray< ShapeClass >::append3x3, ResizeArray< ShapeClass >::append4, ResizeArray< ShapeClass >::append9, ResizeArray< ShapeClass >::appendlist, ResizeArray< ShapeClass >::appendN, and ResizeArray< ShapeClass >::set_size.

template<class T>
ptrdiff_t 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 262 of file ResizeArray.h.

template<class T>
ptrdiff_t ResizeArray< T >::num ( void ) const [inline]

current size of array.

Definition at line 66 of file ResizeArray.h.

Referenced by GeometryList::add_geometry, QuickSurf::calc_surf, DrawMolecule::components, DrawMolecule::current, GraphicsFltkRepOrbital::dataset_append, GraphicsFltkRepVolumetric::dataset_append, GeometryList::del_geometry, GeometryList::do_color_changed, ColorscaleLumaChart::draw, BaseMolecule::find_atom_in_residue, DisplayDevice::find_instance_images, 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, GraphLayout::get_vertex_ptrs, SmallRingLinkages::getLinkageEdge, GeometryList::getTextFormat, GeometryList::getTextOffset, getvalues, SmallRing::last_atom, measure_pbc_neighbors, measure_sasa, measure_sasa_thread, mol_delete_cb, SmallRing::num, MoleculeList::num, Fragment::num, BaseMolecule::num_angles, Scene::num_colorscale_methods, BaseMolecule::num_cterms, BaseMolecule::num_dihedrals, MoleculeGraphics::num_elements, Molecule::num_files, BaseMolecule::num_impropers, BaseMolecule::num_instances, Symmetry::numaxes, DrawMolecule::numframes, Symmetry::numplanes, Symmetry::numrotreflect, DisplayDevice::pick, GeometryList::prepare, py_label_delete, py_label_getvalues, py_label_visible, py_listall, py_measure_angle, py_measure_bond, py_measure_dihed, read_dssp_record, read_stride_record, PSDisplayDevice::render, FileRenderer::render, ToolFltkMenu::reset_device_menus, SmallRing::reverse, sasa, GraphicsFltkRepOrbital::set_values, GeometryList::setTextFormat, GeometryList::setTextOffset, GeometryList::setTextSize, GeometryList::setTextThickness, GeometryList::show_geometry, Buttons::start, Buttons::state, X3DOMDisplayDevice::text, X3DDisplayDevice::text, OSPRayDisplayDevice::text, OSPRay2DisplayDevice::text, OptiXDisplayDevice::text, text_cmd_animate, text_cmd_label, text_cmd_mobile, OpenGLRenderer::update_lists, vmd_measure_angle, vmd_measure_bond, vmd_measure_dihed, vmd_measure_energy, vmd_measure_pbc_neighbors, vmd_measure_sasa, vmd_measure_sasaperresidue, VMDinitialize, VMDreadStartup, write_ss_input_pdb, and MolFilePlugin::write_structure.

template<class T>
T const& ResizeArray< T >::operator[] ( ptrdiff_t N ) const [inline]

a const version of above.

Definition at line 68 of file ResizeArray.h.

template<class T>
T& ResizeArray< T >::operator[] ( ptrdiff_t N ) [inline]

unchecked accessor, for speed.

Definition at line 67 of file ResizeArray.h.

template<class T>
T& ResizeArray< T >::pop ( ) [inline]

remove the last item from the array, unchecked for speed.

Definition at line 243 of file ResizeArray.h.

template<class T>
void ResizeArray< T >::remove ( ptrdiff_t n ) [inline]

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

Definition at line 235 of file ResizeArray.h.

Referenced by GeometryList::del_geometry.

template<class T>
void ResizeArray< T >::set_size ( ptrdiff_t N ) [inline]

Set "occupied" array size to N elements -- Expert use only.

Definition at line 71 of file ResizeArray.h.

template<class T>
void ResizeArray< T >::truncatelastn ( ptrdiff_t N ) [inline]

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

Definition at line 254 of file ResizeArray.h.

Referenced by SmallRing::remove_last.


The documentation for this class was generated from the following file:
Generated on Mon Nov 17 02:48:58 2025 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002

AltStyle によって変換されたページ (->オリジナル) /