nrnhash.h File Reference

#include <ivstream.h>
#include <vector.h>
#include <map.h>
Include dependency graph for nrnhash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define __NrnHashEntry(Table)   Table##_Entry
#define NrnHashEntry(Table)   __NrnHashEntry(Table)
#define __NrnHashLT(Table)   nrnhash_lt_##Table
#define NrnHashLT(Table)   __NrnHashLT(Table)
#define declareNrnHash(Table, Key, Value)
#define implementNrnHash(Table, Key, Value)
#define NrnHashIterate(Table, table, Value, value)

Define Documentation

#define __NrnHashEntry ( Table   )     Table##_Entry
#define __NrnHashLT ( Table   )     nrnhash_lt_##Table
#define declareNrnHash ( Table,
Key,
Value   ) 
Value:
struct NrnHashLT(Table) { \
   int operator() (Key i, Key j) const { \
      return ((unsigned long)i) < ((unsigned long)j); \
   } \
}; \
\
class NrnHashEntry(Table) : public std::map <Key, Value, NrnHashLT(Table)>{}; \
\
class Table : public vector<NrnHashEntry(Table)> { \
public: \
   Table(long size); \
   virtual ~Table(); \
   boolean find(Key, Value&)const; \
   NrnHashEntry(Table)& at(unsigned long bucket){ return *(begin() + bucket); } \
   Value& operator[](Key key) { return at(hash(key))[key]; } \
   void remove(Key); \
   unsigned long hash(Key key)const { return ((unsigned long)key)%size_; } \
   long size_; \
};
#define implementNrnHash ( Table,
Key,
Value   ) 
Value:
Table::Table(long size) { \
   resize(size+1); \
   size_ = size; \
} \
\
Table::~Table() {} \
\
boolean Table::find(Key key, Value& ps)const { \
   NrnHashEntry(Table)::const_iterator itr; \
   const NrnHashEntry(Table)& gm = ((Table*)this)->at(hash(key)); \
   if ((itr = gm.find(key)) == gm.end()) { \
      return false; \
   } \
   ps = itr->second; \
   return true; \
}\
\
void Table::remove(Key key) { \
   NrnHashEntry(Table)& gm = ((Table*)this)->at(hash(key)); \
   gm.erase(key); \
}
#define NrnHashEntry ( Table   )     __NrnHashEntry(Table)
#define NrnHashIterate ( Table,
table,
Value,
value   ) 
Value:
if (table) for (long i__ = table->size_ - 1; i__ >= 0; --i__) { \
      NrnHashEntry(Table)::const_iterator p__ = table->at(i__).begin(); \
      NrnHashEntry(Table)::const_iterator pe__ = table->at(i__).end(); \
      while(p__ != pe__) { \
         Value value = (*p__).second; \
         ++p__; \

Referenced by MultiSplitControl::multisplit_clear(), and nrnmpi_gid_clear().

#define NrnHashLT ( Table   )     __NrnHashLT(Table)
Generated on Mon Jun 13 08:10:28 2011 for NEURON by  doxygen 1.6.3