ug4
ug::SectionContainer< TValue, TContainer > Class Template Reference

A container that is divided into different sections. More...

#include <section_container.h>

Classes

struct  Section
 

Public Types

typedef Container::const_iterator const_iterator
 
typedef TContainer Container
 
typedef Container::iterator iterator
 
typedef TValue value_type
 

Public Member Functions

void append (const SectionContainer &c)
 appends the elements of the given container to the current one More...
 
value_typeback (int secIndex=-1)
 returns the last entry in the given section. More...
 
iterator begin ()
 
const_iterator begin () const
 
void clear ()
 
void clear_section (int sectionIndex)
 
iterator end ()
 
const_iterator end () const
 
void erase (const iterator &iter, int sectionIndex)
 
value_typefront (int secIndex=-1)
 returns the first entry in the given section. More...
 
Containerget_container ()
 returns the container for raw access. More...
 
iterator insert (const TValue &val, int sectionIndex)
 
uint num_elements () const
 
uint num_elements (int sectionIndex) const
 
int num_sections () const
 
iterator section_begin (int sectionIndex)
 
const_iterator section_begin (int sectionIndex) const
 
iterator section_end (int sectionIndex)
 
const_iterator section_end (int sectionIndex) const
 
 SectionContainer ()
 
void transfer_elements (SectionContainer &c)
 takes all elements from the given section container and transfers them to this one. More...
 

Protected Types

typedef std::vector< SectionSectionVec
 

Protected Member Functions

void add_sections (int num)
 

Protected Attributes

Container m_container
 
uint m_numElements
 
SectionVec m_vSections
 

Detailed Description

template<class TValue, class TContainer>
class ug::SectionContainer< TValue, TContainer >

A container that is divided into different sections.

This container can be used to store values that have a common base, but can be sorted in different sections. The SectionContainer supplies you with interfaces to iterate over a certain section or to iterate over the complete container. The SectionContainer works on containers of the standard template library. Be sure, that TContainer holds values of type TValue. TContainer has to support the container operations of a std::list.

Member Typedef Documentation

◆ const_iterator

template<class TValue , class TContainer >
typedef Container::const_iterator ug::SectionContainer< TValue, TContainer >::const_iterator

◆ Container

template<class TValue , class TContainer >
typedef TContainer ug::SectionContainer< TValue, TContainer >::Container

◆ iterator

template<class TValue , class TContainer >
typedef Container::iterator ug::SectionContainer< TValue, TContainer >::iterator

◆ SectionVec

template<class TValue , class TContainer >
typedef std::vector<Section> ug::SectionContainer< TValue, TContainer >::SectionVec
protected

◆ value_type

template<class TValue , class TContainer >
typedef TValue ug::SectionContainer< TValue, TContainer >::value_type

Constructor & Destructor Documentation

◆ SectionContainer()

template<class TValue , class TContainer >
ug::SectionContainer< TValue, TContainer >::SectionContainer

Member Function Documentation

◆ add_sections()

template<class TValue , class TContainer >
void ug::SectionContainer< TValue, TContainer >::add_sections ( int  num)
protected

◆ append()

template<class TValue , class TContainer >
void ug::SectionContainer< TValue, TContainer >::append ( const SectionContainer< TValue, TContainer > &  c)

appends the elements of the given container to the current one

Note that the append operation is performed for each section separately.

Warning
This method should not be used if the underlying container and the given one operate on the same AttachedElemList. Otherwise severe side effect will occur! Use transfer_elements instead!

References ug::SectionContainer< TValue, TContainer >::num_sections(), ug::SectionContainer< TValue, TContainer >::section_begin(), and ug::SectionContainer< TValue, TContainer >::section_end().

Referenced by ug::MultiGridSubsetHandler::join_subset_lists().

◆ back()

template<class TValue , class TContainer >
SectionContainer< TValue, TContainer >::value_type & ug::SectionContainer< TValue, TContainer >::back ( int  secIndex = -1)

returns the last entry in the given section.

use index -1 to get the last entry of the complete chain. Make sure to only call this method if there are elements in the given section at all.

◆ begin() [1/2]

◆ begin() [2/2]

template<class TValue , class TContainer >
const_iterator ug::SectionContainer< TValue, TContainer >::begin ( ) const
inline

◆ clear()

template<class TValue , class TContainer >
void ug::SectionContainer< TValue, TContainer >::clear

◆ clear_section()

template<class TValue , class TContainer >
void ug::SectionContainer< TValue, TContainer >::clear_section ( int  sectionIndex)

◆ end() [1/2]

◆ end() [2/2]

template<class TValue , class TContainer >
const_iterator ug::SectionContainer< TValue, TContainer >::end ( ) const
inline

◆ erase()

template<class TValue , class TContainer >
void ug::SectionContainer< TValue, TContainer >::erase ( const iterator iter,
int  sectionIndex 
)

◆ front()

template<class TValue , class TContainer >
SectionContainer< TValue, TContainer >::value_type & ug::SectionContainer< TValue, TContainer >::front ( int  secIndex = -1)

returns the first entry in the given section.

use index -1 to get the first entry of the complete chain. Make sure to only call this method if there are elements in the given section at all.

◆ get_container()

template<class TValue , class TContainer >
Container& ug::SectionContainer< TValue, TContainer >::get_container ( )
inline

◆ insert()

template<class TValue , class TContainer >
SectionContainer< TValue, TContainer >::iterator ug::SectionContainer< TValue, TContainer >::insert ( const TValue &  val,
int  sectionIndex 
)

◆ num_elements() [1/2]

template<class TValue , class TContainer >
uint ug::SectionContainer< TValue, TContainer >::num_elements ( ) const
inline

◆ num_elements() [2/2]

template<class TValue , class TContainer >
uint ug::SectionContainer< TValue, TContainer >::num_elements ( int  sectionIndex) const

◆ num_sections()

template<class TValue , class TContainer >
int ug::SectionContainer< TValue, TContainer >::num_sections ( ) const
inline

◆ section_begin() [1/2]

template<class TValue , class TContainer >
SectionContainer< TValue, TContainer >::iterator ug::SectionContainer< TValue, TContainer >::section_begin ( int  sectionIndex)

if the section is empty section_begin and section_end return the same iterators. However, no assumptions on the positions of these iterators should be made.

Referenced by ug::SectionContainer< TValue, TContainer >::append(), and ug::SectionContainer< TValue, TContainer >::transfer_elements().

◆ section_begin() [2/2]

template<class TValue , class TContainer >
SectionContainer< TValue, TContainer >::const_iterator ug::SectionContainer< TValue, TContainer >::section_begin ( int  sectionIndex) const

◆ section_end() [1/2]

template<class TValue , class TContainer >
SectionContainer< TValue, TContainer >::iterator ug::SectionContainer< TValue, TContainer >::section_end ( int  sectionIndex)

if the section is empty section_begin and section_end return the same iterators. However, no assumptions on the positions of these iterators should be made.

Referenced by ug::SectionContainer< TValue, TContainer >::append(), and ug::SectionContainer< TValue, TContainer >::transfer_elements().

◆ section_end() [2/2]

template<class TValue , class TContainer >
SectionContainer< TValue, TContainer >::const_iterator ug::SectionContainer< TValue, TContainer >::section_end ( int  sectionIndex) const

◆ transfer_elements()

template<class TValue , class TContainer >
void ug::SectionContainer< TValue, TContainer >::transfer_elements ( SectionContainer< TValue, TContainer > &  c)

Member Data Documentation

◆ m_container

◆ m_numElements

template<class TValue , class TContainer >
uint ug::SectionContainer< TValue, TContainer >::m_numElements
protected

◆ m_vSections

template<class TValue , class TContainer >
SectionVec ug::SectionContainer< TValue, TContainer >::m_vSections
protected

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