foobar2000 SDK  2015-08-03
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Private Types | Private Attributes
pfc::map_t< t_storage_key, t_storage_value, t_comparator >

#include <map.h>

Data Structures

class  comparator_wrapper
 
class  enumeration_wrapper
 
class  enumeration_wrapper_var
 
struct  t_retrieve_key
 
struct  t_search_query
 
struct  t_search_set
 
struct  t_storage
 

Public Types

typedef t_content::const_iterator const_iterator
 
typedef t_content::iterator iterator
 
typedef t_storage_key t_key
 
typedef t_storage_value t_value
 
typedef traits_t< t_contenttraits
 

Public Member Functions

template<typename t_callback >
void enumerate (t_callback &p_callback) const
 
template<typename t_callback >
void enumerate (t_callback &p_callback)
 
template<typename _t_key >
bool exists (const _t_key &p_key) const
 
template<typename _t_key >
iterator find (const _t_key &key)
 
template<typename _t_key >
const_iterator find (const _t_key &key) const
 
template<typename _t_key >
t_storage_value & find_or_add (_t_key const &p_key)
 
template<typename _t_key >
t_storage_value & find_or_add_ex (_t_key const &p_key, bool &p_isnew)
 
iterator first () throw ()
 
const_iterator first () const throw ()
 
t_size get_count () const throw ()
 
template<typename _t_key >
bool get_first (_t_key &p_out) const
 
template<typename _t_key >
bool get_last (_t_key &p_out) const
 
template<typename _t_key >
bool have_item (const _t_key &p_key) const
 
iterator last () throw ()
 
const_iterator last () const throw ()
 
bool operator!= (const t_self &other) const
 
bool operator== (const t_self &other) const
 
template<typename _t_key >
const t_storage_value & operator[] (const _t_key &p_key) const
 
template<typename _t_key >
t_storage_value & operator[] (const _t_key &p_key)
 
template<typename t_source >
void overwrite (const t_source &p_source)
 
template<typename _t_key , typename _t_value >
bool query (const _t_key &p_key, _t_value &p_value) const
 
template<bool inclusive, bool above, typename _t_key , typename _t_value >
bool query_nearest (_t_key &p_key, _t_value &p_value) const
 
template<bool inclusive, bool above, typename _t_key >
const t_storage_value * query_nearest_ptr (_t_key &p_key) const
 
template<bool inclusive, bool above, typename _t_key >
t_storage_value * query_nearest_ptr (_t_key &p_key)
 
template<typename _t_key >
const t_storage_value * query_ptr (const _t_key &p_key) const
 
template<typename _t_key >
t_storage_value * query_ptr (const _t_key &p_key)
 
template<typename _t_key >
bool query_ptr (const _t_key &p_key, const t_storage_value *&out) const
 
template<typename _t_key >
bool query_ptr (const _t_key &p_key, t_storage_value *&out)
 
template<typename _t_key >
bool remove (const _t_key &p_key)
 
bool remove (iterator const &iter)
 
bool remove (const_iterator const &iter)
 
void remove_all () throw ()
 
template<typename _t_key , typename _t_value >
void set (const _t_key &p_key, const _t_value &p_value)
 

Static Public Member Functions

static bool equals (const t_self &v1, const t_self &v2)
 

Private Types

typedef avltree_t< t_storage, comparator_wrappert_content
 
typedef map_t< t_storage_key, t_storage_value, t_comparator > t_self
 

Private Attributes

t_content m_data
 

Detailed Description

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
class pfc::map_t< t_storage_key, t_storage_value, t_comparator >

Definition at line 16 of file map.h.

Member Typedef Documentation

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
typedef t_content::const_iterator pfc::map_t< t_storage_key, t_storage_value, t_comparator >::const_iterator

Definition at line 226 of file map.h.

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
typedef t_content::iterator pfc::map_t< t_storage_key, t_storage_value, t_comparator >::iterator

Definition at line 227 of file map.h.

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
typedef avltree_t<t_storage,comparator_wrapper> pfc::map_t< t_storage_key, t_storage_value, t_comparator >::t_content
private

Definition at line 221 of file map.h.

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
typedef t_storage_key pfc::map_t< t_storage_key, t_storage_value, t_comparator >::t_key

Definition at line 20 of file map.h.

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
typedef map_t<t_storage_key,t_storage_value,t_comparator> pfc::map_t< t_storage_key, t_storage_value, t_comparator >::t_self
private

Definition at line 18 of file map.h.

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
typedef t_storage_value pfc::map_t< t_storage_key, t_storage_value, t_comparator >::t_value

Definition at line 20 of file map.h.

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
typedef traits_t<t_content> pfc::map_t< t_storage_key, t_storage_value, t_comparator >::traits

Definition at line 225 of file map.h.

Member Function Documentation

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename t_callback >
void pfc::map_t< t_storage_key, t_storage_value, t_comparator >::enumerate ( t_callback &  p_callback) const
inline

Definition at line 125 of file map.h.

125  {
126  enumeration_wrapper<t_callback> cb(p_callback);
127  m_data.enumerate(cb);
128  }
t_content m_data
Definition: map.h:223
void enumerate(t_callback &p_callback) const
Definition: avltree.h:458
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename t_callback >
void pfc::map_t< t_storage_key, t_storage_value, t_comparator >::enumerate ( t_callback &  p_callback)
inline

Definition at line 131 of file map.h.

131  {
132  enumeration_wrapper_var<t_callback> cb(p_callback);
134  }
void _enumerate_var(t_callback &p_callback)
Allows callback to modify the tree content. Unsafe! Caller must not modify items in a way that change...
Definition: avltree.h:465
t_content m_data
Definition: map.h:223
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
static bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::equals ( const t_self v1,
const t_self v2 
)
inlinestatic

Definition at line 237 of file map.h.

237  {
238  return t_content::equals(v1.m_data,v2.m_data);
239  }
static bool equals(const t_self &v1, const t_self &v2)
Definition: avltree.h:505
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::exists ( const _t_key &  p_key) const
inline

Definition at line 148 of file map.h.

148 {return have_item(p_key);}
bool have_item(const _t_key &p_key) const
Definition: map.h:39
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
iterator pfc::map_t< t_storage_key, t_storage_value, t_comparator >::find ( const _t_key &  key)
inline

Definition at line 234 of file map.h.

234 {return m_data.find(t_search_query<_t_key>(key));}
t_content m_data
Definition: map.h:223
const_iterator find(t_param const &item) const
Definition: avltree.h:420
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
const_iterator pfc::map_t< t_storage_key, t_storage_value, t_comparator >::find ( const _t_key &  key) const
inline

Definition at line 235 of file map.h.

235 {return m_data.find(t_search_query<_t_key>(key));}
t_content m_data
Definition: map.h:223
const_iterator find(t_param const &item) const
Definition: avltree.h:420
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
t_storage_value& pfc::map_t< t_storage_key, t_storage_value, t_comparator >::find_or_add ( _t_key const &  p_key)
inline

Definition at line 29 of file map.h.

29  {
30  return m_data.add(t_search_query<_t_key>(p_key)).m_value;
31  }
t_storage & add(const t_param &p_item)
Definition: avltree.h:475
t_content m_data
Definition: map.h:223
t_storage_value m_value
Definition: map.h:182
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
t_storage_value& pfc::map_t< t_storage_key, t_storage_value, t_comparator >::find_or_add_ex ( _t_key const &  p_key,
bool &  p_isnew 
)
inline

Definition at line 34 of file map.h.

34  {
35  return m_data.add_ex(t_search_query<_t_key>(p_key),p_isnew).m_value;
36  }
t_content m_data
Definition: map.h:223
t_storage & add_ex(const t_param &p_item, bool &p_isnew)
Definition: avltree.h:476
t_storage_value m_value
Definition: map.h:182
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
iterator pfc::map_t< t_storage_key, t_storage_value, t_comparator >::first ( )
throw (
)
inline

Definition at line 229 of file map.h.

229 {return m_data._first_var();}
t_content m_data
Definition: map.h:223
iterator _first_var()
Unsafe! Caller must not modify items in a way that changes sort order!
Definition: avltree.h:488
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
const_iterator pfc::map_t< t_storage_key, t_storage_value, t_comparator >::first ( ) const
throw (
)
inline

Definition at line 231 of file map.h.

231 {return m_data.first();}
t_content m_data
Definition: map.h:223
const_iterator first() const
Definition: avltree.h:485
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
t_size pfc::map_t< t_storage_key, t_storage_value, t_comparator >::get_count ( ) const
throw (
)
inline

Definition at line 137 of file map.h.

137 {return m_data.get_count();}
t_size get_count() const
Definition: avltree.h:453
t_content m_data
Definition: map.h:223
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::get_first ( _t_key &  p_out) const
inline

Definition at line 151 of file map.h.

151  {
152  return m_data.get_first(t_retrieve_key<_t_key>(p_out));
153  }
bool get_first(t_param &p_item) const
Definition: avltree.h:492
t_content m_data
Definition: map.h:223
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::get_last ( _t_key &  p_out) const
inline

Definition at line 155 of file map.h.

155  {
156  return m_data.get_last(t_retrieve_key<_t_key>(p_out));
157  }
t_content m_data
Definition: map.h:223
bool get_last(t_param &p_item) const
Definition: avltree.h:498
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::have_item ( const _t_key &  p_key) const
inline

Definition at line 39 of file map.h.

39  {
40  return m_data.have_item(t_search_query<_t_key>(p_key));
41  }
t_content m_data
Definition: map.h:223
bool have_item(const t_param &p_item) const
Same as contains().
Definition: avltree.h:433
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
iterator pfc::map_t< t_storage_key, t_storage_value, t_comparator >::last ( )
throw (
)
inline

Definition at line 230 of file map.h.

230 {return m_data._last_var();}
t_content m_data
Definition: map.h:223
iterator _last_var()
Unsafe! Caller must not modify items in a way that changes sort order!
Definition: avltree.h:490
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
const_iterator pfc::map_t< t_storage_key, t_storage_value, t_comparator >::last ( ) const
throw (
)
inline

Definition at line 232 of file map.h.

232 {return m_data.last();}
t_content m_data
Definition: map.h:223
const_iterator last() const
Definition: avltree.h:486
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::operator!= ( const t_self other) const
inline

Definition at line 241 of file map.h.

241 {return !equals(*this,other);}
static bool equals(const t_self &v1, const t_self &v2)
Definition: map.h:237
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::operator== ( const t_self other) const
inline

Definition at line 240 of file map.h.

240 {return equals(*this,other);}
static bool equals(const t_self &v1, const t_self &v2)
Definition: map.h:237
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
const t_storage_value& pfc::map_t< t_storage_key, t_storage_value, t_comparator >::operator[] ( const _t_key &  p_key) const
inline

Definition at line 52 of file map.h.

52  {
53  const t_storage_value * ptr = query_ptr(p_key);
54  if (ptr == NULL) throw exception_map_entry_not_found();
55  return *ptr;
56  }
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
t_storage_value& pfc::map_t< t_storage_key, t_storage_value, t_comparator >::operator[] ( const _t_key &  p_key)
inline

Definition at line 59 of file map.h.

59  {
60  return find_or_add(p_key);
61  }
t_storage_value & find_or_add(_t_key const &p_key)
Definition: map.h:29
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename t_source >
void pfc::map_t< t_storage_key, t_storage_value, t_comparator >::overwrite ( const t_source &  p_source)
inline

Definition at line 142 of file map.h.

142  {
143  __map_overwrite_wrapper<t_self> wrapper(*this);
144  p_source.enumerate(wrapper);
145  }
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key , typename _t_value >
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::query ( const _t_key &  p_key,
_t_value &  p_value 
) const
inline

Definition at line 44 of file map.h.

44  {
45  const t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key));
46  if (storage == NULL) return false;
47  p_value = storage->m_value;
48  return true;
49  }
t_content m_data
Definition: map.h:223
t_storage_value m_value
Definition: map.h:182
const t_storage * find_ptr(t_param const &p_item) const
Definition: avltree.h:477
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<bool inclusive, bool above, typename _t_key , typename _t_value >
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::query_nearest ( _t_key &  p_key,
_t_value &  p_value 
) const
inline

Definition at line 110 of file map.h.

110  {
111  const t_storage * storage = m_data.template find_nearest_item<inclusive,above>(t_search_query<_t_key>(p_key));
112  if (storage == NULL) return false;
113  p_key = storage->m_key;
114  p_value = storage->m_value;
115  return true;
116  }
t_content m_data
Definition: map.h:223
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<bool inclusive, bool above, typename _t_key >
const t_storage_value* pfc::map_t< t_storage_key, t_storage_value, t_comparator >::query_nearest_ptr ( _t_key &  p_key) const
inline

Definition at line 94 of file map.h.

94  {
95  const t_storage * storage = m_data.template find_nearest_item<inclusive,above>(t_search_query<_t_key>(p_key));
96  if (storage == NULL) return NULL;
97  p_key = storage->m_key;
98  return &storage->m_value;
99  }
t_content m_data
Definition: map.h:223
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<bool inclusive, bool above, typename _t_key >
t_storage_value* pfc::map_t< t_storage_key, t_storage_value, t_comparator >::query_nearest_ptr ( _t_key &  p_key)
inline

Definition at line 102 of file map.h.

102  {
103  t_storage * storage = m_data.template find_nearest_item<inclusive,above>(t_search_query<_t_key>(p_key));
104  if (storage == NULL) return NULL;
105  p_key = storage->m_key;
106  return &storage->m_value;
107  }
t_content m_data
Definition: map.h:223
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
const t_storage_value* pfc::map_t< t_storage_key, t_storage_value, t_comparator >::query_ptr ( const _t_key &  p_key) const
inline

Definition at line 64 of file map.h.

64  {
65  const t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key));
66  if (storage == NULL) return NULL;
67  return &storage->m_value;
68  }
t_content m_data
Definition: map.h:223
t_storage_value m_value
Definition: map.h:182
const t_storage * find_ptr(t_param const &p_item) const
Definition: avltree.h:477
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
t_storage_value* pfc::map_t< t_storage_key, t_storage_value, t_comparator >::query_ptr ( const _t_key &  p_key)
inline

Definition at line 71 of file map.h.

71  {
72  t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key));
73  if (storage == NULL) return NULL;
74  return &storage->m_value;
75  }
t_content m_data
Definition: map.h:223
t_storage_value m_value
Definition: map.h:182
const t_storage * find_ptr(t_param const &p_item) const
Definition: avltree.h:477
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::query_ptr ( const _t_key &  p_key,
const t_storage_value *&  out 
) const
inline

Definition at line 78 of file map.h.

78  {
79  const t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key));
80  if (storage == NULL) return false;
81  out = &storage->m_value;
82  return true;
83  }
t_content m_data
Definition: map.h:223
t_storage_value m_value
Definition: map.h:182
const t_storage * find_ptr(t_param const &p_item) const
Definition: avltree.h:477
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::query_ptr ( const _t_key &  p_key,
t_storage_value *&  out 
)
inline

Definition at line 86 of file map.h.

86  {
87  t_storage * storage = m_data.find_ptr(t_search_query<_t_key>(p_key));
88  if (storage == NULL) return false;
89  out = &storage->m_value;
90  return true;
91  }
t_content m_data
Definition: map.h:223
t_storage_value m_value
Definition: map.h:182
const t_storage * find_ptr(t_param const &p_item) const
Definition: avltree.h:477
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key >
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::remove ( const _t_key &  p_key)
inline

Definition at line 120 of file map.h.

120  {
121  return m_data.remove_item(t_search_query<_t_key>(p_key));
122  }
t_content m_data
Definition: map.h:223
bool remove_item(t_param const &p_item)
Definition: avltree.h:447
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::remove ( iterator const &  iter)
inline

Definition at line 243 of file map.h.

243  {
244  PFC_ASSERT(iter.is_valid());
245  return m_data.remove(iter);
246  //should never return false unless there's a bug in calling code
247  }
t_content m_data
Definition: map.h:223
bool remove(const_iterator const &iter)
Definition: avltree.h:440
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
bool pfc::map_t< t_storage_key, t_storage_value, t_comparator >::remove ( const_iterator const &  iter)
inline

Definition at line 248 of file map.h.

248  {
249  PFC_ASSERT(iter.is_valid());
250  return m_data.remove(iter);
251  //should never return false unless there's a bug in calling code
252  }
t_content m_data
Definition: map.h:223
bool remove(const_iterator const &iter)
Definition: avltree.h:440
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
void pfc::map_t< t_storage_key, t_storage_value, t_comparator >::remove_all ( )
throw (
)
inline

Definition at line 139 of file map.h.

139 {m_data.remove_all();}
t_content m_data
Definition: map.h:223
void remove_all()
Definition: avltree.h:435
template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
template<typename _t_key , typename _t_value >
void pfc::map_t< t_storage_key, t_storage_value, t_comparator >::set ( const _t_key &  p_key,
const _t_value &  p_value 
)
inline

Definition at line 22 of file map.h.

22  {
23  bool isnew;
24  t_storage & storage = m_data.add_ex(t_search_set<_t_key,_t_value>(p_key,p_value), isnew);
25  if (!isnew) storage.m_value = p_value;
26  }
t_content m_data
Definition: map.h:223
t_storage & add_ex(const t_param &p_item, bool &p_isnew)
Definition: avltree.h:476
t_storage_value m_value
Definition: map.h:182

Field Documentation

template<typename t_storage_key, typename t_storage_value, typename t_comparator = comparator_default>
t_content pfc::map_t< t_storage_key, t_storage_value, t_comparator >::m_data
private

Definition at line 223 of file map.h.


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