[PD-cvs] externals/nusmuk msd.h,1.2,1.3

Thomas Grill xovo at users.sourceforge.net
Tue May 3 10:45:38 CEST 2005


Update of /cvsroot/pure-data/externals/nusmuk
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28584/nusmuk

Modified Files:
	msd.h 
Log Message:
fixed bitreversing
use flext maps

Index: msd.h
===================================================================
RCS file: /cvsroot/pure-data/externals/nusmuk/msd.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** msd.h	2 May 2005 22:07:18 -0000	1.2
--- msd.h	3 May 2005 08:45:36 -0000	1.3
***************
*** 40,44 ****
  #include <string.h>
  #include <vector>
- #include <map>
  
  // define constants
--- 40,43 ----
***************
*** 219,223 ****
  {
  	T r = 0;
! 	for(int i = 0; i < sizeof(k)*4; ++i) r = (r<<1)|(k&1),k >>= 1;
  	return r;
  }
--- 218,222 ----
  {
  	T r = 0;
! 	for(int i = 0; i < sizeof(k)*8; ++i) r = (r<<1)|(k&1),k >>= 1;
  	return r;
  }
***************
*** 240,244 ****
  	}
  	
! 	inline size_t size() const { return Parent::size(); }
  
  	inline T insert(unsigned int k,T v) { return Parent::insert(bitrev(k),v); }	
--- 239,243 ----
  	}
  	
! 	inline int size() const { return Parent::size(); }
  
  	inline T insert(unsigned int k,T v) { return Parent::insert(bitrev(k),v); }	
***************
*** 260,264 ****
  template <typename T>
  class IDMap
! 	: std::map<const t_symbol *,TablePtrMap<T,T,4> *>
  {
  public:
--- 259,263 ----
  template <typename T>
  class IDMap
! 	: TablePtrMap<const t_symbol *,TablePtrMap<T,T,4> *>
  {
  public:
***************
*** 266,270 ****
  	typedef TablePtrMap<T,T,4> Container;
  	// that's the map for the key ID (symbol,int) relating to the data items
! 	typedef std::map<const t_symbol *,Container *> Parent;
  
  	typedef typename Container::iterator iterator;
--- 265,269 ----
  	typedef TablePtrMap<T,T,4> Container;
  	// that's the map for the key ID (symbol,int) relating to the data items
! 	typedef TablePtrMap<const t_symbol *,Container *> Parent;
  
  	typedef typename Container::iterator iterator;
***************
*** 276,282 ****
  	void reset() 
  	{
!         typename Parent::iterator it;
!         for(it = Parent::begin(); it != Parent::end(); ++it) 
!             delete it->second;
  		Parent::clear();
  	}
--- 275,280 ----
  	void reset() 
  	{
!         typename Parent::iterator it(*this);
!         for(; it; ++it) delete it.data();
  		Parent::clear();
  	}
***************
*** 284,293 ****
  	void insert(T item)
  	{
! 		typename Parent::iterator it = Parent::find(item->Id);
!         Container *c;
!         if(it == Parent::end())
!             Parent::operator[](item->Id) = c = new Container;
!         else
!             c = it->second;
          c->insert(item,item);
  	}
--- 282,288 ----
  	void insert(T item)
  	{
! 		Container *c = Parent::find(item->Id);
!         if(!c)
!             Parent::insert(item->Id,c = new Container);
          c->insert(item,item);
  	}
***************
*** 295,311 ****
  	iterator find(const t_symbol *key)
  	{
! 		typename Parent::iterator it = Parent::find(key);
! 		if(it == Parent::end())
! 			return iterator();
!         else {
!             Container *c = it->second;
  			return iterator(*c);
!         }
  	}
  	
  	void erase(T item)
  	{
! 		typename Parent::iterator it = Parent::find(item->Id);
! 		if(it != Parent::end()) it->second->remove(item);
  	}
  };
--- 290,304 ----
  	iterator find(const t_symbol *key)
  	{
! 		Container *c = Parent::find(key);
! 		if(c)
  			return iterator(*c);
!         else
! 			return iterator();
  	}
  	
  	void erase(T item)
  	{
! 		Container *c = Parent::find(item->Id);
! 		if(c) c->remove(item);
  	}
  };





More information about the Pd-cvs mailing list