libktorrent  2.2.0
Public Types | Public Member Functions | List of all members
bt::PtrMap< Key, Data > Class Template Reference

Map of pointers. More...

#include <ptrmap.h>

Public Types

typedef std::map< Key, Data * >::const_iterator const_iterator
 
typedef std::map< Key, Data * >::iterator iterator
 

Public Member Functions

 PtrMap (bool autodel=false)
 
virtual ~PtrMap ()
 
iterator begin ()
 
const_iterator begin () const
 
void clear ()
 
bool contains (const Key &k) const
 
unsigned int count () const
 
iterator end ()
 
const_iterator end () const
 
virtual bool erase (const Key &key)
 
iterator erase (iterator i)
 
Data * find (const Key &k)
 
const Data * find (const Key &k) const
 
bool insert (const Key &k, Data *d, bool overwrite=true)
 
void setAutoDelete (bool yes)
 

Detailed Description

template<class Key, class Data>
class bt::PtrMap< Key, Data >

Author
Joris Guisson

A Map where the data is a pointer. The PtrMap has an autodeletion feature. When autodelete is on, every time we remove something from the map, the data will be deleted.

Definition at line 37 of file ptrmap.h.

Constructor & Destructor Documentation

◆ PtrMap()

template<class Key , class Data >
bt::PtrMap< Key, Data >::PtrMap ( bool  autodel = false)
inline

Constructor.

Parameters
auto_delWhether or not to enable auto deletion

Definition at line 46 of file ptrmap.h.

◆ ~PtrMap()

template<class Key , class Data >
virtual bt::PtrMap< Key, Data >::~PtrMap ( )
inlinevirtual

Destructor. Will delete all objects, if auto deletion is on.

Definition at line 52 of file ptrmap.h.

Member Function Documentation

◆ clear()

template<class Key , class Data >
void bt::PtrMap< Key, Data >::clear ( )
inline

Remove all objects, will delete them if autodelete is on.

Definition at line 84 of file ptrmap.h.

Referenced by bt::PtrMap< bt::PieceDownloader *, bt::DownloadStatus >::~PtrMap().

◆ contains()

template<class Key , class Data >
bool bt::PtrMap< Key, Data >::contains ( const Key &  k) const
inline

Check to see if a key is in the map.

Parameters
kThe key
Returns
true if it is part of the map

Definition at line 155 of file ptrmap.h.

◆ count()

template<class Key , class Data >
unsigned int bt::PtrMap< Key, Data >::count ( ) const
inline

Return the number of key data pairs in the map.

Definition at line 61 of file ptrmap.h.

◆ erase() [1/2]

template<class Key , class Data >
virtual bool bt::PtrMap< Key, Data >::erase ( const Key &  key)
inlinevirtual

Erase a key from the map. Will delete the data if autodelete is on.

Parameters
keyThe key
Returns
true if an erase took place

Definition at line 167 of file ptrmap.h.

◆ erase() [2/2]

template<class Key , class Data >
iterator bt::PtrMap< Key, Data >::erase ( iterator  i)
inline

Erase an iterator from the map.

Definition at line 182 of file ptrmap.h.

◆ find() [1/2]

template<class Key , class Data >
Data* bt::PtrMap< Key, Data >::find ( const Key &  k)
inline

Find a key in the map and returns it's data.

Parameters
kThe key
Returns
The data of the key, 0 if the key isn't in the map

Definition at line 133 of file ptrmap.h.

◆ find() [2/2]

template<class Key , class Data >
const Data* bt::PtrMap< Key, Data >::find ( const Key &  k) const
inline

Find a key in the map and returns it's data.

Parameters
kThe key
Returns
The data of the key, 0 if the key isn't in the map

Definition at line 144 of file ptrmap.h.

◆ insert()

template<class Key , class Data >
bool bt::PtrMap< Key, Data >::insert ( const Key &  k,
Data *  d,
bool  overwrite = true 
)
inline

Insert a key data pair.

Parameters
kThe key
dThe data
overwriteWhether or not to overwrite
Returns
true if the insertion took place

Definition at line 104 of file ptrmap.h.

◆ setAutoDelete()

template<class Key , class Data >
void bt::PtrMap< Key, Data >::setAutoDelete ( bool  yes)
inline

Enable or disable auto deletion.

Parameters
yesEnable if true, disable if false

Definition at line 67 of file ptrmap.h.


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