bpp-seq3  3.0.0
bpp::VectorMappedContainer< T > Class Template Referenceabstract

The template VectorMappedContainer class. More...

#include <Bpp/Seq/Container/VectorMappedContainer.h>

+ Inheritance diagram for bpp::VectorMappedContainer< T >:
+ Collaboration diagram for bpp::VectorMappedContainer< T >:

Public Member Functions

 VectorMappedContainer ()
 
 VectorMappedContainer (const VectorMappedContainer &vsc)
 
VectorMappedContainer< T > & operator= (const VectorMappedContainer &vsc)
 
virtual ~VectorMappedContainer ()
 
size_t getSize () const override
 Get the number of objects in the container. More...
 
size_t getNumberOfObjects () const
 
size_t getObjectPosition (const std::string &name) const override
 Link between position & name. More...
 
const std::string & getObjectName (size_t objectIndex) const override
 
std::vector< std::string > getObjectNames () const override
 
void setObjectNames (const std::vector< std::string > &names)
 
void setObjectName (size_t pos, const std::string &name)
 
void addObject (std::shared_ptr< T > newObject, size_t objectIndex, const std::string &name, bool check=false) override
 
void insertObject (std::shared_ptr< T > newObject, size_t objectIndex, const std::string &name) override
 
virtual void appendObject (std::shared_ptr< T > newObject, const std::string &name, bool checkNames=true)
 
std::shared_ptr< T > removeObject (size_t objectIndex) override
 Extract and remove a object from the container. More...
 
void deleteObject (size_t objectIndex) override
 Delete an object from the container. More...
 
std::shared_ptr< T > removeObject (const std::string &name) override
 Remove and returns an object. More...
 
void deleteObject (const std::string &name) override
 Remove an object. More...
 
void addObject_ (std::shared_ptr< T > newObject, size_t objectIndex, const std::string &name, bool check=false) const
 
void clear () override
 Delete all objects in the container. More...
 
void nullify () override
 Nullify all elements. More...
 
virtual void setSize (size_t size)
 
virtual const std::shared_ptr< T > getObject (size_t objectIndex) const =0
 Retrieve an object from the container. More...
 
virtual std::shared_ptr< T > getObject (size_t objectIndex)=0
 Retrieve an object from the container. More...
 
virtual const T & object (size_t objectIndex) const =0
 Get a reference toward an object from the container. More...
 
virtual T & object (size_t objectIndex)=0
 Get a reference toward an object from the container. More...
 
const std::shared_ptr< T > getObject (const std::string &name) const override
 Retrieve an object from the container. More...
 
std::shared_ptr< T > getObject (const std::string &name) override
 
const T & object (const std::string &name) const override
 
T & object (const std::string &name) override
 
bool hasObject (const std::string &name) const override
 Check if a object with a given name is present in the container. More...
 
void addObject (std::shared_ptr< T > newObject, const std::string &name, bool checkName=false)
 Set an object. More...
 
void changeName (const std::string &okey, const std::string &nkey)
 change the key of an object. More...
 
bool isAvailableName (std::string objectName) const
 
void addObject_ (std::shared_ptr< T > newObject, const std::string &name, bool checkName=false) const
 
bool isAvailablePosition (size_t objectIndex) const
 
bool hasObjectWithPosition (size_t objectIndex) const
 
void setSize (size_t size) override
 
const std::shared_ptr< T > getObject (size_t objectIndex) const override
 Retrieve an object from the container. More...
 
std::shared_ptr< T > getObject (size_t objectIndex) override
 Retrieve an object from the container. More...
 
const T & object (size_t objectIndex) const override
 Get a reference toward an object from the container. More...
 
T & object (size_t objectIndex) override
 Get a reference toward an object from the container. More...
 
void addObject (std::shared_ptr< T > object, size_t objectIndex, bool checkPosition=false)
 Add an object. More...
 
void insertObject (std::shared_ptr< T > object, size_t objectIndex)
 Insert an object. More...
 
void deleteObjects (size_t objectIndex, size_t length)
 
void appendObject (std::shared_ptr< T > object)
 
std::shared_ptr< T > getObject_ (size_t objectIndex) const
 
void addObject_ (std::shared_ptr< T > object, size_t objectIndex, bool checkPosition=false) const
 
The Clonable interface.
VectorMappedContainer< T > * clone () const override
 

Protected Member Functions

virtual const std::shared_ptr< T > getObject (const std::string &name) const =0
 Retrieve an object from the container. More...
 
virtual std::shared_ptr< T > getObject (const std::string &name)=0
 
virtual const T & object (const std::string &name) const =0
 
virtual T & object (const std::string &name)=0
 
virtual bool hasObject (const std::string &name) const =0
 Check if a object with a given name is present in the container. More...
 

Protected Attributes

std::vector< std::shared_ptr< T > > positions_
 

Private Attributes

std::vector< std::string > vNames_
 vector of the names, in same order as objects More...
 
std::map< std::string, size_t > mNames_
 map <string, size_t> for the positions of the names More...
 
std::map< std::string, std::shared_ptr< T > > mObjects_
 

Detailed Description

template<class T>
class bpp::VectorMappedContainer< T >

The template VectorMappedContainer class.

Objects are stored in a std::vector of shared pointers and in a map of shared pointers.

Object access is hence in $O(1)$ through indexes, and $O(log(n))$ through names.

Definition at line 31 of file VectorMappedContainer.h.

Constructor & Destructor Documentation

◆ VectorMappedContainer() [1/2]

template<class T >
bpp::VectorMappedContainer< T >::VectorMappedContainer ( )
inline

Definition at line 48 of file VectorMappedContainer.h.

Referenced by bpp::VectorMappedContainer< T >::clone().

◆ VectorMappedContainer() [2/2]

template<class T >
bpp::VectorMappedContainer< T >::VectorMappedContainer ( const VectorMappedContainer< T > &  vsc)
inline

Definition at line 55 of file VectorMappedContainer.h.

◆ ~VectorMappedContainer()

template<class T >
virtual bpp::VectorMappedContainer< T >::~VectorMappedContainer ( )
inlinevirtual

Definition at line 72 of file VectorMappedContainer.h.

Member Function Documentation

◆ addObject() [1/3]

template<class T >
void bpp::MappedNamedContainer< T >::addObject ( std::shared_ptr< T >  newObject,
const std::string &  name,
bool  checkName = false 
)
inlineinherited

Set an object.

Parameters
nameThe key of the object.
newObjectThe new object that will be associated to the key.
checkNameTell is the object name must be checked.

Definition at line 110 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::hasObject(), and bpp::MappedNamedContainer< T >::mObjects_.

Referenced by bpp::VectorMappedContainer< T >::addObject(), bpp::VectorMappedContainer< T >::appendObject(), and bpp::VectorMappedContainer< T >::insertObject().

◆ addObject() [2/3]

◆ addObject() [3/3]

template<class T >
void bpp::VectorPositionedContainer< T >::addObject ( std::shared_ptr< T >  object,
size_t  objectIndex,
bool  checkPosition = false 
)
inlineinherited

◆ addObject_() [1/3]

template<class T >
void bpp::MappedNamedContainer< T >::addObject_ ( std::shared_ptr< T >  newObject,
const std::string &  name,
bool  checkName = false 
) const
inlineinherited

◆ addObject_() [2/3]

template<class T >
void bpp::VectorMappedContainer< T >::addObject_ ( std::shared_ptr< T >  newObject,
size_t  objectIndex,
const std::string &  name,
bool  check = false 
) const
inline

◆ addObject_() [3/3]

template<class T >
void bpp::VectorPositionedContainer< T >::addObject_ ( std::shared_ptr< T >  object,
size_t  objectIndex,
bool  checkPosition = false 
) const
inlineinherited

◆ appendObject() [1/2]

◆ appendObject() [2/2]

◆ changeName()

template<class T >
void bpp::MappedNamedContainer< T >::changeName ( const std::string &  okey,
const std::string &  nkey 
)
inlineinherited

change the key of an object.

Parameters
okeyThe present key of the object.
nkeyThe next key of the object.

Definition at line 168 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::hasObject(), and bpp::MappedNamedContainer< T >::mObjects_.

Referenced by bpp::VectorMappedContainer< T >::setObjectName(), and bpp::VectorMappedContainer< T >::setObjectNames().

◆ clear()

◆ clone()

template<class T >
VectorMappedContainer<T>* bpp::VectorMappedContainer< T >::clone ( ) const
inlineoverridevirtual

◆ deleteObject() [1/2]

template<class T >
void bpp::VectorMappedContainer< T >::deleteObject ( const std::string &  name)
inlineoverridevirtual

Remove an object.

Parameters
nameThe key of the object.

Reimplemented from bpp::MappedNamedContainer< T >.

Definition at line 227 of file VectorMappedContainer.h.

References bpp::VectorMappedContainer< T >::deleteObject(), and bpp::VectorMappedContainer< T >::mNames_.

◆ deleteObject() [2/2]

◆ deleteObjects()

◆ getNumberOfObjects()

template<class T >
size_t bpp::VectorMappedContainer< T >::getNumberOfObjects ( ) const
inline

◆ getObject() [1/8]

template<class T >
virtual const std::shared_ptr<T> bpp::NamedContainerInterface< T >::getObject ( const std::string &  name) const
protectedpure virtualinherited

Retrieve an object from the container.

Parameters
nameThe name of the object.
Returns
A reference toward the Object with corresponding name.

Implemented in bpp::MappedNamedContainer< T >.

◆ getObject() [2/8]

template<class T >
const std::shared_ptr<T> bpp::MappedNamedContainer< T >::getObject ( const std::string &  name) const
inlineoverridevirtualinherited

Retrieve an object from the container.

Parameters
nameThe name of the object.
Returns
A reference toward the Object with corresponding name.

Implements bpp::NamedContainerInterface< T >.

Definition at line 61 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::mObjects_.

Referenced by bpp::MappedNamedContainer< T >::isAvailableName(), bpp::TemplateVectorSequenceContainer< SequenceType >::sequence(), and bpp::TemplateVectorSiteContainer< SiteType, SequenceType >::sequence().

◆ getObject() [3/8]

template<class T >
std::shared_ptr<T> bpp::MappedNamedContainer< T >::getObject ( const std::string &  name)
inlineoverridevirtualinherited

◆ getObject() [4/8]

template<class T >
virtual std::shared_ptr<T> bpp::NamedContainerInterface< T >::getObject ( const std::string &  name)
protectedpure virtualinherited

◆ getObject() [5/8]

template<class T >
virtual const std::shared_ptr<T> bpp::PositionedContainerInterface< T >::getObject ( size_t  objectIndex) const
pure virtualinherited

Retrieve an object from the container.

Parameters
objectIndexThe position of the object.
Returns
A shared pointer toward the Object object with corresponding name.

Implemented in bpp::VectorPositionedContainer< T >, bpp::VectorPositionedContainer< bpp::Site >, and bpp::VectorPositionedContainer< SiteType >.

◆ getObject() [6/8]

template<class T >
const std::shared_ptr<T> bpp::VectorPositionedContainer< T >::getObject ( size_t  objectIndex) const
inlineoverridevirtualinherited

Retrieve an object from the container.

Parameters
objectIndexThe position of the object.
Returns
A shared pointer toward the Object object with corresponding name.

Implements bpp::PositionedContainerInterface< T >.

Definition at line 127 of file VectorPositionedContainer.h.

References bpp::VectorPositionedContainer< T >::getSize(), and bpp::VectorPositionedContainer< T >::positions_.

Referenced by bpp::TemplateAlignedSequenceContainer< SequenceType, SiteType >::site(), bpp::TemplateVectorSiteContainer< SiteType, SequenceType >::site(), and bpp::TemplateVectorSiteContainer< SiteType, SequenceType >::site_().

◆ getObject() [7/8]

template<class T >
std::shared_ptr<T> bpp::VectorPositionedContainer< T >::getObject ( size_t  objectIndex)
inlineoverridevirtualinherited

Retrieve an object from the container.

Parameters
objectIndexThe position of the object.
Returns
A shared pointer toward the Object object with corresponding name.

Implements bpp::PositionedContainerInterface< T >.

Definition at line 134 of file VectorPositionedContainer.h.

References bpp::VectorPositionedContainer< T >::getSize(), and bpp::VectorPositionedContainer< T >::positions_.

◆ getObject() [8/8]

template<class T >
virtual std::shared_ptr<T> bpp::PositionedContainerInterface< T >::getObject ( size_t  objectIndex)
pure virtualinherited

Retrieve an object from the container.

Parameters
objectIndexThe position of the object.
Returns
A shared pointer toward the Object object with corresponding name.

Implemented in bpp::VectorPositionedContainer< T >, bpp::VectorPositionedContainer< bpp::Site >, and bpp::VectorPositionedContainer< SiteType >.

◆ getObject_()

template<class T >
std::shared_ptr<T> bpp::VectorPositionedContainer< T >::getObject_ ( size_t  objectIndex) const
inlineinherited

◆ getObjectName()

◆ getObjectNames()

template<class T >
std::vector<std::string> bpp::VectorMappedContainer< T >::getObjectNames ( ) const
inlineoverridevirtual

◆ getObjectPosition()

template<class T >
size_t bpp::VectorMappedContainer< T >::getObjectPosition ( const std::string &  name) const
inlineoverridevirtual

◆ getSize()

template<class T >
size_t bpp::VectorMappedContainer< T >::getSize ( ) const
inlineoverridevirtual

Get the number of objects in the container.

Returns
The number of objects in the container.

Reimplemented from bpp::MappedNamedContainer< T >.

Definition at line 92 of file VectorMappedContainer.h.

References bpp::VectorPositionedContainer< T >::getSize().

Referenced by bpp::TemplateVectorSequenceContainer< SequenceType >::getNumberOfSequences(), and bpp::VectorMappedContainer< T >::getObjectName().

◆ hasObject() [1/2]

template<class T >
virtual bool bpp::NamedContainerInterface< T >::hasObject ( const std::string &  name) const
protectedpure virtualinherited

Check if a object with a given name is present in the container.

Parameters
nameThe name of the object.
Returns
True if a object with the given name is present in the container.

Implemented in bpp::MappedNamedContainer< T >.

◆ hasObject() [2/2]

◆ hasObjectWithPosition()

template<class T >
bool bpp::VectorPositionedContainer< T >::hasObjectWithPosition ( size_t  objectIndex) const
inlineinherited

◆ insertObject() [1/2]

◆ insertObject() [2/2]

template<class T >
void bpp::VectorPositionedContainer< T >::insertObject ( std::shared_ptr< T >  object,
size_t  objectIndex 
)
inlineinherited

◆ isAvailableName()

template<class T >
bool bpp::MappedNamedContainer< T >::isAvailableName ( std::string  objectName) const
inlineinherited
Returns
whether the name is in the map keys and the mapped object is nullptr or empty.

Definition at line 195 of file MappedNamedContainer.h.

References bpp::MappedNamedContainer< T >::getObject(), and bpp::MappedNamedContainer< T >::hasObject().

Referenced by bpp::TemplateVectorSiteContainer< SiteType, SequenceType >::sequence().

◆ isAvailablePosition()

template<class T >
bool bpp::VectorPositionedContainer< T >::isAvailablePosition ( size_t  objectIndex) const
inlineinherited

◆ nullify()

◆ object() [1/8]

template<class T >
virtual const T& bpp::NamedContainerInterface< T >::object ( const std::string &  name) const
protectedpure virtualinherited

◆ object() [2/8]

template<class T >
const T& bpp::MappedNamedContainer< T >::object ( const std::string &  name) const
inlineoverridevirtualinherited

◆ object() [3/8]

template<class T >
T& bpp::MappedNamedContainer< T >::object ( const std::string &  name)
inlineoverridevirtualinherited

◆ object() [4/8]

template<class T >
virtual T& bpp::NamedContainerInterface< T >::object ( const std::string &  name)
protectedpure virtualinherited

◆ object() [5/8]

template<class T >
virtual const T& bpp::PositionedContainerInterface< T >::object ( size_t  objectIndex) const
pure virtualinherited

Get a reference toward an object from the container.

Parameters
objectIndexThe position of the object.
Returns
A reference toward the Object object with corresponding name.

Implemented in bpp::VectorPositionedContainer< T >, bpp::VectorPositionedContainer< bpp::Site >, and bpp::VectorPositionedContainer< SiteType >.

◆ object() [6/8]

template<class T >
const T& bpp::VectorPositionedContainer< T >::object ( size_t  objectIndex) const
inlineoverridevirtualinherited

Get a reference toward an object from the container.

Parameters
objectIndexThe position of the object.
Returns
A reference toward the Object object with corresponding name.

Implements bpp::PositionedContainerInterface< T >.

Definition at line 141 of file VectorPositionedContainer.h.

References bpp::VectorPositionedContainer< T >::getSize(), and bpp::VectorPositionedContainer< T >::positions_.

Referenced by bpp::VectorPositionedContainer< T >::addObject().

◆ object() [7/8]

template<class T >
T& bpp::VectorPositionedContainer< T >::object ( size_t  objectIndex)
inlineoverridevirtualinherited

Get a reference toward an object from the container.

Parameters
objectIndexThe position of the object.
Returns
A reference toward the Object object with corresponding name.

Implements bpp::PositionedContainerInterface< T >.

Definition at line 148 of file VectorPositionedContainer.h.

References bpp::VectorPositionedContainer< T >::getSize(), and bpp::VectorPositionedContainer< T >::positions_.

◆ object() [8/8]

template<class T >
virtual T& bpp::PositionedContainerInterface< T >::object ( size_t  objectIndex)
pure virtualinherited

Get a reference toward an object from the container.

Parameters
objectIndexThe position of the object.
Returns
A reference toward the Object object with corresponding name.

Implemented in bpp::VectorPositionedContainer< T >, bpp::VectorPositionedContainer< bpp::Site >, and bpp::VectorPositionedContainer< SiteType >.

◆ operator=()

◆ removeObject() [1/2]

template<class T >
std::shared_ptr<T> bpp::VectorMappedContainer< T >::removeObject ( const std::string &  name)
inlineoverridevirtual

Remove and returns an object.

Parameters
nameThe key of the object.
Returns
The object previously associated to the given key.

Reimplemented from bpp::MappedNamedContainer< T >.

Definition at line 222 of file VectorMappedContainer.h.

References bpp::VectorMappedContainer< T >::mNames_, and bpp::VectorMappedContainer< T >::removeObject().

◆ removeObject() [2/2]

template<class T >
std::shared_ptr<T> bpp::VectorMappedContainer< T >::removeObject ( size_t  objectIndex)
inlineoverridevirtual

◆ setObjectName()

template<class T >
void bpp::VectorMappedContainer< T >::setObjectName ( size_t  pos,
const std::string &  name 
)
inline

◆ setObjectNames()

◆ setSize() [1/2]

template<class T >
virtual void bpp::PositionedContainerInterface< T >::setSize ( size_t  size)
inlinevirtualinherited

◆ setSize() [2/2]

Member Data Documentation

◆ mNames_

◆ mObjects_

◆ positions_

◆ vNames_


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