Loading...
Searching...
No Matches
ompl::PDF< _T > Class Template Reference

A container that supports probabilistic sampling over weighted data. More...

#include <ompl/datastructures/PDF.h>

Classes

class  Element
 A class that will hold data contained in the PDF. More...
 

Public Member Functions

 PDF ()=default
 Constructs an empty PDF.
 
 PDF (const std::vector< _T > &d, const std::vector< double > &weights)
 Constructs a PDF containing a given vector of data with given weights.
 
 ~PDF ()
 Destructor. Clears allocated memory.
 
const std::vector< Element * > & getElements ()
 Get the current set of stored elements.
 
Elementadd (const _T &d, const double w)
 Adds a piece of data with a given weight to the PDF. Returns a corresponding Element, which can be used to subsequently update or remove the data from the PDF.
 
_T & sample (double r) const
 Returns a piece of data from the PDF according to the input sampling value, which must be between 0 and 1.
 
void update (Element *elem, const double w)
 Updates the data in the given Element with a new weight value.
 
double getWeight (const Element *elem) const
 Returns the current weight of the given Element.
 
void remove (Element *elem)
 Removes the data in the given Element from the PDF. After calling this function, the Element object should no longer be used.
 
void clear ()
 Clears the PDF.
 
std::size_t size () const
 Returns the number of elements in the PDF.
 
const _T & operator[] (unsigned int i) const
 Returns indexed data from the PDF, according to order of insertion.
 
bool empty () const
 Returns whether the PDF contains no data.
 
void printTree (std::ostream &out=std::cout) const
 Prints the PDF tree to a given output stream. Used for debugging purposes.
 

Detailed Description

template<typename _T>
class ompl::PDF< _T >

A container that supports probabilistic sampling over weighted data.

Definition at line 48 of file PDF.h.

Constructor & Destructor Documentation

◆ PDF()

template<typename _T >
ompl::PDF< _T >::PDF ( const std::vector< _T > & d,
const std::vector< double > & weights )
inline

Constructs a PDF containing a given vector of data with given weights.

Definition at line 71 of file PDF.h.

◆ ~PDF()

template<typename _T >
ompl::PDF< _T >::~PDF ( )
inline

Destructor. Clears allocated memory.

Definition at line 84 of file PDF.h.

Member Function Documentation

◆ add()

template<typename _T >
Element * ompl::PDF< _T >::add ( const _T & d,
const double w )
inline

Adds a piece of data with a given weight to the PDF. Returns a corresponding Element, which can be used to subsequently update or remove the data from the PDF.

Definition at line 97 of file PDF.h.

◆ clear()

template<typename _T >
void ompl::PDF< _T >::clear ( )
inline

Clears the PDF.

Definition at line 242 of file PDF.h.

◆ empty()

template<typename _T >
bool ompl::PDF< _T >::empty ( ) const
inline

Returns whether the PDF contains no data.

Definition at line 263 of file PDF.h.

◆ getElements()

template<typename _T >
const std::vector< Element * > & ompl::PDF< _T >::getElements ( )
inline

Get the current set of stored elements.

Definition at line 90 of file PDF.h.

◆ getWeight()

template<typename _T >
double ompl::PDF< _T >::getWeight ( const Element * elem) const
inline

Returns the current weight of the given Element.

Definition at line 171 of file PDF.h.

◆ operator[]()

template<typename _T >
const _T & ompl::PDF< _T >::operator[] ( unsigned int i) const
inline

Returns indexed data from the PDF, according to order of insertion.

Definition at line 257 of file PDF.h.

◆ printTree()

template<typename _T >
void ompl::PDF< _T >::printTree ( std::ostream & out = std::cout) const
inline

Prints the PDF tree to a given output stream. Used for debugging purposes.

Definition at line 269 of file PDF.h.

◆ remove()

template<typename _T >
void ompl::PDF< _T >::remove ( Element * elem)
inline

Removes the data in the given Element from the PDF. After calling this function, the Element object should no longer be used.

Definition at line 178 of file PDF.h.

◆ sample()

template<typename _T >
_T & ompl::PDF< _T >::sample ( double r) const
inline

Returns a piece of data from the PDF according to the input sampling value, which must be between 0 and 1.

Definition at line 132 of file PDF.h.

◆ size()

template<typename _T >
std::size_t ompl::PDF< _T >::size ( ) const
inline

Returns the number of elements in the PDF.

Definition at line 251 of file PDF.h.

◆ update()

template<typename _T >
void ompl::PDF< _T >::update ( Element * elem,
const double w )
inline

Updates the data in the given Element with a new weight value.

Definition at line 155 of file PDF.h.


The documentation for this class was generated from the following file:
  • ompl/datastructures/PDF.h