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

A SymbolList object. More...

#include <Bpp/Seq/SymbolList.h>

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

Public Member Functions

 SymbolList (const Alphabet *alpha)
 Build a new void SymbolList object with the specified alphabet. More...
 
 SymbolList (const std::vector< T > &list, const Alphabet *alpha)
 Build a new SymbolList object with the specified alphabet. The content of the site is initialized from a vector of T objects. More...
 
 SymbolList (const SymbolList< T > &list)
 The generic copy constructor. More...
 
 SymbolList (const CoreSymbolList< T > &list)
 The copy constructor. More...
 
SymbolList< T > & operator= (const CoreSymbolList< T > &list)
 The generic assignment operator. More...
 
SymbolList< T > & operator= (const SymbolList< T > &list)
 The assignment operator. More...
 
virtual ~SymbolList ()
 
const AlphabetgetAlphabet () const
 Get the alphabet associated to the list. More...
 
size_t size () const
 Get the number of elements in the list. More...
 
virtual void setContent (const std::vector< T > &list)
 Set the whole content of the list. More...
 
virtual const std::vector< T > & getContent () const
 
virtual std::string toString () const
 Convert the list as a string. More...
 
void deleteElement (size_t pos)
 Remove the element at position 'pos'. More...
 
void deleteElements (size_t pos, size_t len)
 Remove the elements at position 'pos'. More...
 
void addElement (const T &v)
 Add a character to the end of the list. More...
 
void addElement (size_t pos, const T &v)
 Add a character at a certain position in the list. More...
 
void setElement (size_t pos, const T &v)
 Set the element at position 'pos' to character 'c'. More...
 
virtual const T & getElement (size_t pos) const
 Get the element at position 'pos' as a character. More...
 
virtual const T & getValue (size_t pos) const
 checked access to a character in list. More...
 
virtual const T & operator[] (size_t pos) const
 Operator [] overloaded for quick access to a character in list. More...
 
virtual T & operator[] (size_t pos)
 Operator [] overloaded for quick access to a character in list. More...
 
virtual void shuffle ()
 Randomly shuffle the content of the list, with linear complexity. More...
 
virtual double getStateValueAt (size_t siteIndex, int state) const
 
virtual double operator() (size_t siteIndex, int state) const
 
The Clonable interface
virtual SymbolList< T > * clone () const =0
 

Protected Attributes

std::vector< T > content_
 The list content. More...
 

Private Attributes

const Alphabetalphabet_
 The Alphabet attribute must be initialized in constructor and then can never be changed. More...
 

Detailed Description

template<class T>
class bpp::SymbolList< T >

A SymbolList object.

This is a general purpose container, containing an ordered list of T states. The states that allowed to be present in the list are defined by an alphabet object, which is passed to the list constructor by a pointer.

See also
Alphabet

Definition at line 70 of file SymbolList.h.

Constructor & Destructor Documentation

◆ SymbolList() [1/4]

template<class T >
bpp::SymbolList< T >::SymbolList ( const Alphabet alpha)
inline

Build a new void SymbolList object with the specified alphabet.

Parameters
alphaThe alphabet to use.

Definition at line 94 of file SymbolList.h.

◆ SymbolList() [2/4]

template<class T >
bpp::SymbolList< T >::SymbolList ( const std::vector< T > &  list,
const Alphabet alpha 
)
inline

Build a new SymbolList object with the specified alphabet. The content of the site is initialized from a vector of T objects.

Parameters
listThe content of the site.
alphaThe alphabet to use.

Definition at line 104 of file SymbolList.h.

References bpp::SymbolList< T >::setContent().

◆ SymbolList() [3/4]

template<class T >
bpp::SymbolList< T >::SymbolList ( const SymbolList< T > &  list)
inline

The generic copy constructor.

Definition at line 114 of file SymbolList.h.

◆ SymbolList() [4/4]

template<class T >
bpp::SymbolList< T >::SymbolList ( const CoreSymbolList< T > &  list)
inline

The copy constructor.

Definition at line 122 of file SymbolList.h.

References bpp::SymbolList< T >::content_, and bpp::CruxSymbolList::size().

◆ ~SymbolList()

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

Definition at line 166 of file SymbolList.h.

Member Function Documentation

◆ addElement() [1/2]

template<class T >
void bpp::SymbolList< T >::addElement ( const T &  c)
inlinevirtual

Add a character to the end of the list.

Parameters
cThe character to add.

Implements bpp::CoreSymbolList< T >.

Reimplemented in bpp::EdSymbolList< T >.

Definition at line 199 of file SymbolList.h.

References bpp::SymbolList< T >::content_.

Referenced by bpp::EdSymbolList< T >::addElement().

◆ addElement() [2/2]

template<class T >
void bpp::SymbolList< T >::addElement ( size_t  pos,
const T &  c 
)
inlinevirtual

Add a character at a certain position in the list.

Parameters
posThe postion where to insert the element.
cThe character to add.

Implements bpp::CoreSymbolList< T >.

Reimplemented in bpp::EdSymbolList< T >.

Definition at line 204 of file SymbolList.h.

References bpp::SymbolList< T >::content_, and bpp::SymbolList< T >::size().

◆ clone()

◆ deleteElement()

template<class T >
void bpp::SymbolList< T >::deleteElement ( size_t  pos)
inlinevirtual

Remove the element at position 'pos'.

Parameters
posThe position of the element to remove.

Implements bpp::CruxSymbolList.

Reimplemented in bpp::EdSymbolList< T >, and bpp::EdSymbolList< int >.

Definition at line 185 of file SymbolList.h.

References bpp::SymbolList< T >::content_, and bpp::SymbolList< T >::size().

Referenced by bpp::EdSymbolList< T >::deleteElement().

◆ deleteElements()

template<class T >
void bpp::SymbolList< T >::deleteElements ( size_t  pos,
size_t  len 
)
inlinevirtual

Remove the elements at position 'pos'.

Parameters
posThe position of the first element to remove.
lenThe length of the region to remove.

Implements bpp::CruxSymbolList.

Reimplemented in bpp::EdSymbolList< T >, and bpp::EdSymbolList< int >.

Definition at line 192 of file SymbolList.h.

References bpp::SymbolList< T >::content_, and bpp::SymbolList< T >::size().

Referenced by bpp::EdSymbolList< T >::deleteElements().

◆ getAlphabet()

◆ getContent()

template<class T >
virtual const std::vector<T>& bpp::SymbolList< T >::getContent ( ) const
inlinevirtual

Implements bpp::CoreSymbolList< T >.

Definition at line 178 of file SymbolList.h.

References bpp::SymbolList< T >::content_.

◆ getElement()

template<class T >
virtual const T& bpp::SymbolList< T >::getElement ( size_t  pos) const
inlinevirtual

Get the element at position 'pos' as a character.

Parameters
posThe position of the character to retrieve.

Implements bpp::CoreSymbolList< T >.

Definition at line 220 of file SymbolList.h.

References bpp::SymbolList< T >::content_, and bpp::SymbolList< T >::size().

◆ getStateValueAt()

◆ getValue()

template<class T >
virtual const T& bpp::SymbolList< T >::getValue ( size_t  pos) const
inlinevirtual

checked access to a character in list.

Parameters
posThe position to retrieve.
Returns
The T value of character at position pos.

Implements bpp::CoreSymbolList< T >.

Definition at line 227 of file SymbolList.h.

References bpp::SymbolList< T >::content_, and bpp::SymbolList< T >::size().

Referenced by bpp::CodonSiteTools::generateCodonSiteWithoutRareVariant(), bpp::CodonSiteTools::isFourFoldDegenerated(), and bpp::CodonSiteTools::numberOfSubstitutions().

◆ operator()()

virtual double bpp::CruxSymbolList::operator() ( size_t  siteIndex,
int  state 
) const
inlinevirtualinherited

◆ operator=() [1/2]

template<class T >
SymbolList<T>& bpp::SymbolList< T >::operator= ( const CoreSymbolList< T > &  list)
inline

◆ operator=() [2/2]

template<class T >
SymbolList<T>& bpp::SymbolList< T >::operator= ( const SymbolList< T > &  list)
inline

The assignment operator.

Definition at line 149 of file SymbolList.h.

References bpp::SymbolList< T >::alphabet_, and bpp::SymbolList< T >::content_.

◆ operator[]() [1/2]

template<class T >
virtual T& bpp::SymbolList< T >::operator[] ( size_t  pos)
inlinevirtual

Operator [] overloaded for quick access to a character in list.

Parameters
posThe position to retrieve.
Returns
The T value of character at position pos.

Implements bpp::CoreSymbolList< T >.

Definition at line 236 of file SymbolList.h.

References bpp::SymbolList< T >::content_.

◆ operator[]() [2/2]

template<class T >
virtual const T& bpp::SymbolList< T >::operator[] ( size_t  pos) const
inlinevirtual

Operator [] overloaded for quick access to a character in list.

Parameters
posThe position to retrieve.
Returns
The T value of character at position pos.

Implements bpp::CoreSymbolList< T >.

Definition at line 234 of file SymbolList.h.

References bpp::SymbolList< T >::content_.

◆ setContent()

template<class T >
virtual void bpp::SymbolList< T >::setContent ( const std::vector< T > &  list)
inlinevirtual

Set the whole content of the list.

Parameters
listThe new content of the list.
See also
The list constructor for information about the way lists are internaly stored.

Implements bpp::CoreSymbolList< T >.

Reimplemented in bpp::EdSymbolList< T >, bpp::EdSymbolList< int >, bpp::SequenceWithAnnotation, bpp::BasicSequence, bpp::EdIntSymbolList, and bpp::BasicIntSymbolList.

Definition at line 173 of file SymbolList.h.

References bpp::SymbolList< T >::content_.

Referenced by bpp::BasicIntSymbolList::setContent(), bpp::EdSymbolList< T >::setContent(), and bpp::SymbolList< T >::SymbolList().

◆ setElement()

template<class T >
void bpp::SymbolList< T >::setElement ( size_t  pos,
const T &  c 
)
inlinevirtual

Set the element at position 'pos' to character 'c'.

Parameters
posThe position of the character to set.
cThe value of the element.

Implements bpp::CoreSymbolList< T >.

Reimplemented in bpp::EdSymbolList< T >.

Definition at line 212 of file SymbolList.h.

References bpp::SymbolList< T >::content_, and bpp::SymbolList< T >::size().

Referenced by bpp::EdSymbolList< T >::setElement().

◆ shuffle()

template<class T >
virtual void bpp::SymbolList< T >::shuffle ( )
inlinevirtual

Randomly shuffle the content of the list, with linear complexity.

Implements bpp::CruxSymbolList.

Definition at line 238 of file SymbolList.h.

References bpp::SymbolList< T >::content_.

◆ size()

◆ toString()

template<class T >
virtual std::string bpp::SymbolList< T >::toString ( ) const
inlinevirtual

Convert the list as a string.

This method is useful for dumping a list to a file or to the screen for display.

Returns
The whole list as a string.

Implements bpp::CruxSymbolList.

Reimplemented in bpp::BasicSequence, bpp::EdIntSymbolList, and bpp::BasicIntSymbolList.

Definition at line 180 of file SymbolList.h.

Member Data Documentation

◆ alphabet_

template<class T >
const Alphabet* bpp::SymbolList< T >::alphabet_
private

The Alphabet attribute must be initialized in constructor and then can never be changed.

To apply another alphabet to a list you'll have to create a new list.

Definition at line 79 of file SymbolList.h.

Referenced by bpp::SymbolList< T >::getAlphabet(), and bpp::SymbolList< T >::operator=().

◆ content_


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