diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2004-03-06 03:25:48 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2004-03-06 03:25:48 +0000 |
commit | cab9975c6fda854b3da7d0530cf8fa22693f6b52 (patch) | |
tree | a8b46172eb4bab18dd7d6b0aac79727aaf92d541 /externals/grill/flext/source/flsupport.h | |
parent | b64e9490db6b6c93009260c0f2651f96f2099ebc (diff) |
""
svn path=/trunk/; revision=1380
Diffstat (limited to 'externals/grill/flext/source/flsupport.h')
-rw-r--r-- | externals/grill/flext/source/flsupport.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index d61f6013..f8191fd3 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -17,6 +17,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flstdc.h" #include <new> +#include <map> /*! \defgroup FLEXT_SUPPORT Flext support classes @{ @@ -1146,6 +1147,50 @@ inline bool operator <=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF inline bool operator >(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) > 0; } inline bool operator >=(const t_atom &a,const t_atom &b) { return FLEXT_CLASSDEF(flext)::CmpAtom(a,b) >= 0; } + +class AnyMap: + public std::map<unsigned int,unsigned int> +{ + typedef std::map<unsigned int,unsigned int> Parent; +public: + AnyMap(); + ~AnyMap(); + iterator find(unsigned int k); + unsigned int &operator [](unsigned int k); + + typedef std::pair<unsigned int,unsigned int> pair; +}; + +template <class K,class T> +class DataMap: + public AnyMap +{ +public: + class iterator: + public AnyMap::iterator + { + public: + iterator() {} + iterator(AnyMap::iterator it): AnyMap::iterator(it) {} + + inline K &key() const { return *(K *)&((*this)->first); } + inline T &data() const { return *(T *)&((*this)->second); } + }; + + class pair: + public AnyMap::pair + { + public: + inline K &key() const { return *(K *)&first; } + inline T &data() const { return *(T *)&second; } + }; + + inline iterator find(K k) { return AnyMap::find(*(unsigned int *)&k); } + inline T &operator [](K k) { return *(T *)&(AnyMap::operator [](*(unsigned int *)&k)); } + inline void erase(K k) { AnyMap::erase(*(unsigned int *)&k); } +}; + + //! @} // FLEXT_SUPPORT #endif |