From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03437.html | 1909 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1909 insertions(+) create mode 100644 docs/doxygen/nel/a03437.html (limited to 'docs/doxygen/nel/a03437.html') diff --git a/docs/doxygen/nel/a03437.html b/docs/doxygen/nel/a03437.html new file mode 100644 index 00000000..79b0a79e --- /dev/null +++ b/docs/doxygen/nel/a03437.html @@ -0,0 +1,1909 @@ + + +NeL: TemplateNLMISC::CStaticMap< Key, Typ, Comp > class Reference + + + +
+

NLMISC::CStaticMap< Key, Typ, Comp > Class Template Reference

#include <static_map.h> +

+


Detailed Description

+

template<class Key, class Typ, class Comp = std::less<Key>>
+ class NLMISC::CStaticMap< Key, Typ, Comp >

+ +Implemented with a std::vector Use it not like a map : begin by adding all your values with add()/del()/fromMap() and then call endAdd() that performs a slow sort on the vector and then call find() to find the element you want. If you have not called endAdd() its done in find(), but take care that endAdd() is slow.
Author:
Matthieu 'Trap' Besson

+Nevrax France

+
Date:
October 2003
+ +

+ +

+Definition at line 57 of file static_map.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Public Types

typedef std::vector< value_type
+>::const_iterator 
const_iterator
typedef std::vector< value_type
+>::const_reference 
const_reference
typedef std::vector< value_type
+>::const_reverse_iterator 
const_reverse_iterator
typedef Typ data_type
typedef std::vector< value_type
+>::difference_type 
difference_type
typedef std::vector< value_type
+>::iterator 
iterator
typedef Comp key_compare
typedef Key key_type
typedef Typ mapped_type
typedef std::vector< value_type
+>::reference 
reference
typedef std::vector< value_type
+>::reverse_iterator 
reverse_iterator
typedef std::vector< value_type
+>::size_type 
size_type
typedef std::pair< Key, Typ > value_type

Public Member Functions

void add (const value_type &__v)
const_iterator begin () const
iterator begin ()
void clear ()
size_type count (const key_type &__x) const
 CStaticMap (const CStaticMap< Key, Typ, Comp > &__x)
 CStaticMap (const_iterator __first, const_iterator __last, const Comp &__comp)
 CStaticMap (const_iterator __first, const_iterator __last)
 CStaticMap (const Comp &__comp)
 CStaticMap ()
void del (iterator __first, iterator __last)
size_type del (const key_type &__x)
void del (iterator __position)
bool empty () const
const_iterator end () const
iterator end ()
void endAdd ()
const_iterator find (const key_type &__x) const
iterator find (const key_type &__x)
void fromMap (const std::map< Key, Typ, Comp > &m)
key_compare key_comp () const
size_type max_size () const
CStaticMap< Key, Typ, Comp > & operator= (const CStaticMap< Key, Typ, Comp > &__x)
Typ & operator[] (const key_type &__k)
const_reverse_iterator rbegin () const
reverse_iterator rbegin ()
const_reverse_iterator rend () const
reverse_iterator rend ()
void reserve (size_type n)
size_type size () const
void swap (CStaticMap< Key, Typ, Comp > &__x)
value_compare value_comp () const

Private Attributes

Comp _CompFunc
std::vector< value_type_Data
bool _DataSorted
+


Member Typedef Documentation

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef std::vector<value_type>::const_iterator NLMISC::CStaticMap< Key, Typ, Comp >::const_iterator +
+
+ + + + + +
+   + + +

+ +

+Definition at line 93 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef std::vector<value_type>::const_reference NLMISC::CStaticMap< Key, Typ, Comp >::const_reference +
+
+ + + + + +
+   + + +

+ +

+Definition at line 91 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef std::vector<value_type>::const_reverse_iterator NLMISC::CStaticMap< Key, Typ, Comp >::const_reverse_iterator +
+
+ + + + + +
+   + + +

+ +

+Definition at line 95 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef Typ NLMISC::CStaticMap< Key, Typ, Comp >::data_type +
+
+ + + + + +
+   + + +

+ +

+Definition at line 61 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef std::vector<value_type>::difference_type NLMISC::CStaticMap< Key, Typ, Comp >::difference_type +
+
+ + + + + +
+   + + +

+ +

+Definition at line 97 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef std::vector<value_type>::iterator NLMISC::CStaticMap< Key, Typ, Comp >::iterator +
+
+ + + + + +
+   + + +

+ +

+Definition at line 92 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef Comp NLMISC::CStaticMap< Key, Typ, Comp >::key_compare +
+
+ + + + + +
+   + + +

+ +

+Definition at line 64 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef Key NLMISC::CStaticMap< Key, Typ, Comp >::key_type +
+
+ + + + + +
+   + + +

+ +

+Definition at line 60 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef Typ NLMISC::CStaticMap< Key, Typ, Comp >::mapped_type +
+
+ + + + + +
+   + + +

+ +

+Definition at line 62 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef std::vector<value_type>::reference NLMISC::CStaticMap< Key, Typ, Comp >::reference +
+
+ + + + + +
+   + + +

+ +

+Definition at line 90 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef std::vector<value_type>::reverse_iterator NLMISC::CStaticMap< Key, Typ, Comp >::reverse_iterator +
+
+ + + + + +
+   + + +

+ +

+Definition at line 94 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef std::vector<value_type>::size_type NLMISC::CStaticMap< Key, Typ, Comp >::size_type +
+
+ + + + + +
+   + + +

+ +

+Definition at line 96 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
typedef std::pair<Key, Typ> NLMISC::CStaticMap< Key, Typ, Comp >::value_type +
+
+ + + + + +
+   + + +

+ +

+Definition at line 63 of file static_map.h.

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
NLMISC::CStaticMap< Key, Typ, Comp >::CStaticMap  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 101 of file static_map.h. +

+

00101                      : _DataSorted(true)
+00102         {
+00103         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
NLMISC::CStaticMap< Key, Typ, Comp >::CStaticMap const Comp &  __comp  )  [inline, explicit]
+
+ + + + + +
+   + + +

+ +

+Definition at line 105 of file static_map.h. +

+

00105                                                  : _DataSorted(true)
+00106         {
+00107         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
NLMISC::CStaticMap< Key, Typ, Comp >::CStaticMap const_iterator  __first,
const_iterator  __last
[inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 109 of file static_map.h. +

+

00110         {
+00111                 _DataSorted = false;
+00112                 _Data.insert(__first, __last);
+00113                 endAdd();
+00114         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
NLMISC::CStaticMap< Key, Typ, Comp >::CStaticMap const_iterator  __first,
const_iterator  __last,
const Comp &  __comp
[inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 116 of file static_map.h. +

+

00117                 : _CompFunc(__comp) 
+00118         { 
+00119                 _DataSorted = false;
+00120                 _Data.insert(__first, __last);
+00121                 endAdd();
+00122         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
NLMISC::CStaticMap< Key, Typ, Comp >::CStaticMap const CStaticMap< Key, Typ, Comp > &  __x  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 124 of file static_map.h. +

+

00125                 : _Data(__x._Data) , _DataSorted(__x._DataSorted), _CompFunc(__x._CompFunc)
+00126         {
+00127         }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
void NLMISC::CStaticMap< Key, Typ, Comp >::add const value_type __v  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 173 of file static_map.h. +

+

00174         { 
+00175                 _DataSorted = false;
+00176                 _Data.push_back (__v); 
+00177         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
const_iterator NLMISC::CStaticMap< Key, Typ, Comp >::begin void   )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 141 of file static_map.h. +

+

00141 { return _Data.begin(); }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
iterator NLMISC::CStaticMap< Key, Typ, Comp >::begin void   )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 140 of file static_map.h. +

+

00140 { return _Data.begin(); }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
void NLMISC::CStaticMap< Key, Typ, Comp >::clear void   )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 213 of file static_map.h. +

+

00214         {
+00215                 _Data.clear();
+00216         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
size_type NLMISC::CStaticMap< Key, Typ, Comp >::count const key_type __x  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 242 of file static_map.h. +

+

00243         { 
+00244                 endAdd();
+00245                 return find(__x) == _Data.end() ? 0 : 1;
+00246         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
void NLMISC::CStaticMap< Key, Typ, Comp >::del iterator  __first,
iterator  __last
[inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 208 of file static_map.h. +

+

00209         {
+00210                 _Data.erase (__first, __last);
+00211         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
size_type NLMISC::CStaticMap< Key, Typ, Comp >::del const key_type __x  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 203 of file static_map.h. +

+

00204         {
+00205                 return _Data.erase (__x);
+00206         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
void NLMISC::CStaticMap< Key, Typ, Comp >::del iterator  __position  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 198 of file static_map.h. +

+

00199         {
+00200                 _Data.erase (__position);
+00201         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
bool NLMISC::CStaticMap< Key, Typ, Comp >::empty  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 148 of file static_map.h. +

+

00148 { return _Data.empty(); }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
const_iterator NLMISC::CStaticMap< Key, Typ, Comp >::end void   )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 143 of file static_map.h. +

+

00143 { return _Data.end(); }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
iterator NLMISC::CStaticMap< Key, Typ, Comp >::end void   )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 142 of file static_map.h. +

+Referenced by NLMISC::CStaticMap< uint32, CChar >::find(), and NLMISC::CStaticMap< uint32, CChar >::operator[](). +

+

00142 { return _Data.end(); }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
void NLMISC::CStaticMap< Key, Typ, Comp >::endAdd  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 189 of file static_map.h. +

+Referenced by NLMISC::CStaticMap< uint32, CChar >::count(), NLMISC::CStaticMap< uint32, CChar >::CStaticMap(), NLMISC::CStaticMap< uint32, CChar >::find(), and NLMISC::CStaticMap< uint32, CChar >::operator=(). +

+

00190         {
+00191                 if (_DataSorted) return;
+00192                 _DataSorted = true;
+00193                 sort (_Data.begin(), _Data.end(), value_comp());        // Sort the vector
+00194         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
const_iterator NLMISC::CStaticMap< Key, Typ, Comp >::find const key_type __x  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 231 of file static_map.h. +

+

00232         {
+00233                 endAdd();
+00234                 value_type __v(__x, Typ());
+00235                 iterator it = lower_bound((const_iterator)_Data.begin(), (const_iterator)_Data.end(), __v, value_comp());
+00236                 if ((it != end()) && (!value_comp()(*it,__v) && !value_comp()(__v,*it)))
+00237                         return it;
+00238                 else
+00239                         return end();
+00240         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
iterator NLMISC::CStaticMap< Key, Typ, Comp >::find const key_type __x  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 220 of file static_map.h. +

+Referenced by NLMISC::CStaticMap< uint32, CChar >::count(), and NLMISC::CStaticMap< uint32, CChar >::operator[](). +

+

00221         {
+00222                 endAdd();
+00223                 value_type __v(__x, Typ());
+00224                 iterator it = lower_bound((iterator)_Data.begin(), (iterator)_Data.end(), __v, value_comp());
+00225                 if ((it != end()) && (!value_comp()(*it,__v) && !value_comp()(__v,*it)))
+00226                         return it;
+00227                 else
+00228                         return end();
+00229         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
void NLMISC::CStaticMap< Key, Typ, Comp >::fromMap const std::map< Key, Typ, Comp > &  m  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 179 of file static_map.h. +

+

00180         {
+00181                 _DataSorted = false;
+00182                 _Data.reserve(m.size());
+00183                 typename std::map<Key,Typ,Comp>::const_iterator itEnd = m.end();
+00184                 typename std::map<Key,Typ,Comp>::const_iterator it = m.begin();
+00185                 for (; it != itEnd; it++)
+00186                         _Data.push_back (std::pair<Key, Typ>::pair(it->first, it->second));
+00187         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
key_compare NLMISC::CStaticMap< Key, Typ, Comp >::key_comp  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 138 of file static_map.h. +

+

00138 { return _Data.key_comp(); }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
size_type NLMISC::CStaticMap< Key, Typ, Comp >::max_size  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 150 of file static_map.h. +

+

00150 { return _Data.max_size(); }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
CStaticMap<Key, Typ, Comp>& NLMISC::CStaticMap< Key, Typ, Comp >::operator= const CStaticMap< Key, Typ, Comp > &  __x  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 129 of file static_map.h. +

+

00130         {
+00131                 _Data = __x._Data;
+00132                 endAdd();
+00133                 return *this; 
+00134         }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
Typ& NLMISC::CStaticMap< Key, Typ, Comp >::operator[] const key_type __k  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 152 of file static_map.h. +

+

00153         {
+00154                 iterator __i = find(__k);
+00155                 // The key MUST exist no automatic insertion done in this class
+00156                 nlassert(__i != end())
+00157                 return (*__i).second;
+00158         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
const_reverse_iterator NLMISC::CStaticMap< Key, Typ, Comp >::rbegin  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 145 of file static_map.h. +

+

00145 { return _Data.rbegin(); }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
reverse_iterator NLMISC::CStaticMap< Key, Typ, Comp >::rbegin  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 144 of file static_map.h. +

+

00144 { return _Data.rbegin(); }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
const_reverse_iterator NLMISC::CStaticMap< Key, Typ, Comp >::rend  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 147 of file static_map.h. +

+

00147 { return _Data.rend(); }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
reverse_iterator NLMISC::CStaticMap< Key, Typ, Comp >::rend  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 146 of file static_map.h. +

+

00146 { return _Data.rend(); }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
void NLMISC::CStaticMap< Key, Typ, Comp >::reserve size_type  n  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 168 of file static_map.h. +

+

00169         {
+00170                 _Data.reserve(n);
+00171         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
size_type NLMISC::CStaticMap< Key, Typ, Comp >::size  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 149 of file static_map.h. +

+

00149 { return _Data.size(); }
+
+

+ + + + +
+ + + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
void NLMISC::CStaticMap< Key, Typ, Comp >::swap CStaticMap< Key, Typ, Comp > &  __x  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 160 of file static_map.h. +

+

00161         {
+00162                 _Data.swap (__x._Data);
+00163                 _DataSorted = false;
+00164         }
+
+

+ + + + +
+ + + + + + + + + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
value_compare NLMISC::CStaticMap< Key, Typ, Comp >::value_comp  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 139 of file static_map.h. +

+Referenced by NLMISC::CStaticMap< uint32, CChar >::endAdd(), and NLMISC::CStaticMap< uint32, CChar >::find(). +

+

00139 { return value_compare(_CompFunc); }
+
+


Field Documentation

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
Comp NLMISC::CStaticMap< Key, Typ, Comp >::_CompFunc [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 85 of file static_map.h.

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
std::vector<value_type> NLMISC::CStaticMap< Key, Typ, Comp >::_Data [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 83 of file static_map.h. +

+Referenced by NLMISC::CStaticMap< uint32, CChar >::operator=(), and NLMISC::CStaticMap< uint32, CChar >::swap().

+

+ + + + +
+ + + + + +
+template<class Key, class Typ, class Comp = std::less<Key>>
bool NLMISC::CStaticMap< Key, Typ, Comp >::_DataSorted [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 84 of file static_map.h.

+


The documentation for this class was generated from the following file: +
Generated on Tue Mar 16 13:34:29 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1