ug4
ug::PointerConstArray< TPtr > Class Template Reference

Container which holds an array of pointers. More...

#include <pointer_const_array.h>

Public Member Functions

void clear ()
 clears the container More...
 
bool empty () const
 returns true if the associated array is empty More...
 
PointerConstArrayoperator= (const PointerConstArray &pa)
 
TPtr const operator[] (size_t i) const
 returns the i-th entry of the array. Make sure that i < size(). More...
 
 PointerConstArray ()
 
 PointerConstArray (const PointerConstArray &pa)
 
void push_back (TPtr p)
 appends the given pointer at the end of the array. More...
 
void reserve (size_t capacity)
 reserves memory but does not alter the size More...
 
void set_external_array (TPtr const *array, size_t size, bool bCopy=false)
 set the array on which the container operates. More...
 
size_t size () const
 returns the size of the associated array. More...
 
 ~PointerConstArray ()
 

Private Types

typedef TPtr const * ConstPtrArray
 
typedef TPtr * PtrArray
 

Private Member Functions

void assign_pointer_const_array (const PointerConstArray &pa)
 copies contents from the given PointerConstArray More...
 
void reserve (size_t capacity, bool copyOldData)
 reserves the specified memory and optionally copies old data More...
 

Private Attributes

ConstPtrArray m_array
 
size_t m_capacity
 
PtrArray m_data
 
size_t m_size
 

Detailed Description

template<class TPtr>
class ug::PointerConstArray< TPtr >

Container which holds an array of pointers.

Gives access to an array of elements of type TPtr. TPtr is assumed to be a pointer type and treated as thus. This means it has to support assignment of NULL. Furthermore no destructors are called when an array is cleared or shrinks. Operators +(int) and ++ also have to be supported.

The array provided by PointerArray is either managed by the PointerArray class itself or can be set from outside.

If an external array is set from outside, the contents will not be copied, unless indicated otherwise. Instead only the pointer is stored and used. The class will not take responsibility over the lifetime of that array. That means that the user is responsible to make sure that the external array, to which the class points to, is valid when accessed.

If the user however uses the methods reserve or push_back, then dedicated memory is allocated and managed by the class itself. This memory is freed when no longer needed.

If an array was set from outside and push_back is called, then the contents of the external array are copied to the local memory of the class.

Note that no memory is freed when clear is called. To make sure that all internal memory is freed, you have to assign an empty instance to the class.

Note that entries of this container may not be changed once they have been added!

If in doubt whether this class should be used, or if a std::vector<TPtr> would be more appropriate, you should most likely choose the std::vector. The main purpose of this class is to allow optional access to an array existing outside of the class itself.

Todo:

: Add iterators

: Implement analogous PointerArray with additional resize method, which allows to change existing entries.

Member Typedef Documentation

◆ ConstPtrArray

template<class TPtr >
typedef TPtr const* ug::PointerConstArray< TPtr >::ConstPtrArray
private

◆ PtrArray

template<class TPtr >
typedef TPtr* ug::PointerConstArray< TPtr >::PtrArray
private

Constructor & Destructor Documentation

◆ PointerConstArray() [1/2]

template<class TPtr >
ug::PointerConstArray< TPtr >::PointerConstArray

◆ PointerConstArray() [2/2]

template<class TPtr >
ug::PointerConstArray< TPtr >::PointerConstArray ( const PointerConstArray< TPtr > &  pa)

◆ ~PointerConstArray()

template<class TPtr >
ug::PointerConstArray< TPtr >::~PointerConstArray

Member Function Documentation

◆ assign_pointer_const_array()

template<class TPtr >
void ug::PointerConstArray< TPtr >::assign_pointer_const_array ( const PointerConstArray< TPtr > &  pa)
private

copies contents from the given PointerConstArray

The method assumes, that all internal memory has been freed prior to calling this method!

References ug::PointerConstArray< TPtr >::m_array, ug::PointerConstArray< TPtr >::m_data, and ug::PointerConstArray< TPtr >::m_size.

◆ clear()

template<class TPtr >
void ug::PointerConstArray< TPtr >::clear

clears the container

The methods sets the internal size to 0, but does not change the capacity. If you want to free the memory of a container, either delete it or assign an empty one.

Referenced by ug::AdaptiveRegularRefiner_MultiGrid::create_closure_elements_2d(), ug::AdaptiveRegularRefiner_MultiGrid::create_closure_elements_3d(), ug::Grid::get_associated(), ug::Grid::get_associated_sorted(), and ug::Grid::get_associated_vols_raw().

◆ empty()

template<class TPtr >
bool ug::PointerConstArray< TPtr >::empty
inline

returns true if the associated array is empty

Referenced by ug::ConvertToTetrahedra(), ug::TangentialSmooth(), and ug::TangentialSmoothSimple().

◆ operator=()

template<class TPtr >
PointerConstArray< TPtr > & ug::PointerConstArray< TPtr >::operator= ( const PointerConstArray< TPtr > &  pa)

◆ operator[]()

template<class TPtr >
TPtr const ug::PointerConstArray< TPtr >::operator[] ( size_t  i) const
inline

returns the i-th entry of the array. Make sure that i < size().

Note that this is a read only operation and that entries in the associated array may not be changed once they were added.

References UG_ASSERT.

◆ push_back()

template<class TPtr >
void ug::PointerConstArray< TPtr >::push_back ( TPtr  p)

appends the given pointer at the end of the array.

If the capacity is too small, it is doubled before the element is appended.

References p.

Referenced by ug::AdaptiveRegularRefiner_MultiGrid::create_closure_elements_3d(), ug::Grid::get_associated_sorted(), ug::Grid::get_associated_vols_raw(), and ug::RemoveDuplicates().

◆ reserve() [1/2]

template<class TPtr >
void ug::PointerConstArray< TPtr >::reserve ( size_t  capacity)

reserves memory but does not alter the size

Note that the method does not free memory if the new capacity is lower than the current capacity.

Referenced by ug::HangingNodeRefinerBase< TSelector >::assign_hnode_marks(), and ug::LocalMarkAdjuster::ref_marks_changed().

◆ reserve() [2/2]

template<class TPtr >
void ug::PointerConstArray< TPtr >::reserve ( size_t  capacity,
bool  copyOldData 
)
private

reserves the specified memory and optionally copies old data

◆ set_external_array()

template<class TPtr >
void ug::PointerConstArray< TPtr >::set_external_array ( TPtr const *  array,
size_t  size,
bool  bCopy = false 
)

set the array on which the container operates.

The container will not take ownership over the array until bCopy is set to true. The caller is thus responsible to free the array if necessary.

Note
entries in the external entry will not be changed at any time by this class or through use of this class.
Setting an external array does not affect the capacity of this container, unless bCopy is set to true.

Referenced by ug::Grid::get_associated(), and ug::Grid::get_associated_sorted().

◆ size()

template<class TPtr >
size_t ug::PointerConstArray< TPtr >::size
inline

returns the size of the associated array.

Referenced by ug::AdaptionSurfaceGridFunction< TDomain >::ValueAccessor::access_closure(), ug::AdaptSurfaceGridToCylinder(), ug::AdjustEdgeOrientationToFaceOrientation(), ug::grid_global_debug_info_provider::ass_elem_in_subset(), ug::grid_global_debug_info_provider::ass_elem_in_subsets(), ug::HangingNodeRefinerBase< TSelector >::assign_hnode_marks(), ug::HangingNodeRefiner_MultiGrid::assign_hnode_marks(), ug::AssignSelectionStateToSides(), ug::lg_ntree_traits_base< tree_dim, world_dim, elem_t_, common_data_t_ >::calculate_bounding_box(), ug::lg_ntree_traits_base< tree_dim, world_dim, elem_t_, common_data_t_ >::calculate_center(), ug::IsBoundaryOrManifodFace::callback(), ug::CheckElementConsistency(), ug::CheckHangingNodeConstrainingFace(), ug::CheckValences(), ug::CollapseEdge(), ug::HangingNodeRefiner_MultiGrid::collect_objects_for_coarsen(), ug::CollectConstraining(), ug::CollectUnconnectedSides(), ug::SubdivisionProjector::concerned_nbr_faces(), ug::DoFDistribution::constrained_edge_dof_indices(), ug::DoFDistribution::constrained_edge_indices(), ug::DoFDistribution::constrained_face_dof_indices(), ug::DoFDistribution::constrained_face_indices(), ug::DoFDistribution::constrained_vertex_dof_indices(), ug::DoFDistribution::constrained_vertex_indices(), ug::CopySubsetFromHigherDimNbr(), ug::CopySubsetIndicesToSides(), ug::AdaptiveRegularRefiner_MultiGrid::create_closure_elements_2d(), ug::AdaptiveRegularRefiner_MultiGrid::create_closure_elements_3d(), ug::DoFDistribution::dof_indices(), ug::ElementDiameterSq(), ug::EvaluateGradientJump_Norm(), ug::EvaluateGradientJump_SideIntegral(), ug::ExportGridToSWC(), ug::DoFDistribution::extract_inner_algebra_indices(), ug::ExtrudeLayers(), ug::FixFaceOrientation(), ug::ParallelDualGraph< TGeomBaseObj, TIndexType, TConnectingObj >::generate_graph(), ug::DegeneratedLayerManager< dim >::get_layer_sides(), ug::GetConnectingEdge(), ug::GetInnerEdgesOfFaceSoup(), ug::GetNeighborhood(), ug::GetSharedSide(), ug::GetSmallestLocalSubsetDimension(), ug::PeriodicBoundaryManager::handle_creation(), ug::DoFDistribution::indices(), ug::DoFDistribution::indices_on_vertex(), ug::DelaunayInfo< TAAPos >::init_marks(), ug::IntegralNormalComponentOnManifoldGeneral(), ug::IntersectCloseEdges(), ug::LaplacianSmooth(), ug::long_edges_of_anisotropic_elem(), ug::SurfaceView::mark_sides_as_surface_or_shadow(), ug::MarkAnisotropic(), ug::MarkAnisotropic_LongEdges(), ug::MarkAnisotropicOnlyX(), ug::MarkCorners(), ug::MarkForAdaption_ElementsTouchingSubset(), ug::MarkForAdaption_GradientAverage(), ug::MarkForAnisotropicRefinement(), ug::MarkForRefinement_CloseToSurface(), ug::MarkForRefinement_SubsetInterfaceElements(), ug::MarkForRefinementByDirection(), ug::SubdivisionProjector::nbr_crease_edges(), ug::NbrIsInSubset(), ug::SubdivisionProjector::new_vertex(), ug::NumAssociatedEdges(), ug::NumAssociatedFaces(), ug::CrouzeixRaviartElemTransfer< TDomain >::prolongate(), ug::LocalMarkAdjuster::ref_marks_changed(), ug::MGHNodeAdjuster::ref_marks_changed(), ug::ShadowCopyAdjuster::ref_marks_changed(), ug::StdHNodeAdjuster::ref_marks_changed(), ug::SubdivisionProjector::refinement_begins(), ug::SmoothProjector::refinement_ends(), ug::RemoveDuplicates(), ug::ReplaceByQuadrilaterals_EdgeBased(), ug::ReplaceByQuadrilaterals_EdgeBasedNoSort(), ug::ReplaceLowValenceVertices(), ug::ReplaceValence3Vertices(), ug::SelectChildrenOfSelectedShadowRimEdges(), ug::SelectChildrenOfSelectedShadowRimFaces(), ug::SelectChildrenOfSelectedShadowVertices(), ug::SelectLinkedElements(), ug::SelectShortPolychains(), ug::SlopeSmooth(), ug::TangentialSmooth(), ug::TangentialSmoothSimple(), ug::WeightedEdgeSmooth(), ug::WeightedFaceSmooth(), ug::WeightedNormalSmooth(), and ug::GridWriterVTU::write_cells().

Member Data Documentation

◆ m_array

template<class TPtr >
ConstPtrArray ug::PointerConstArray< TPtr >::m_array
private

◆ m_capacity

template<class TPtr >
size_t ug::PointerConstArray< TPtr >::m_capacity
private

◆ m_data

template<class TPtr >
PtrArray ug::PointerConstArray< TPtr >::m_data
private

◆ m_size

template<class TPtr >
size_t ug::PointerConstArray< TPtr >::m_size
private

The documentation for this class was generated from the following files: