NEURON
sptfifoq.h
Go to the documentation of this file.
1 //#ifndef tqueue_h
2 //#define tqueue_h
3 
4 // fifo for the NetCons and PreSyns with same delay. Splay tree for
5 // others (especially SelfEvents).
6 // note that most methods below assume a TQItem is in the splay tree
7 // For the fifo part, only insert_fifo, and remove make sense,
8 // and forall_callback does the splay tree first and then the fifo (so
9 // not in time order)
10 #define COLLECT_TQueue_STATISTICS 1
11 struct SPTREE;
12 
13 class TQItem {
14 public:
15  TQItem();
16  virtual ~TQItem();
17  bool check();
18  void clear(){};
19 public:
20  void* data_;
21  double t_;
22  TQItem* left_; // in the fifo, this is toward the head
23  TQItem* right_; // in the fifo, this is toward the tail
24  TQItem* parent_; // in the fifo, this is unused
25  int cnt_; // reused: -1 means it is in the fifo
26 };
27 
28 // helper class for the TQueue (SplayTFifoQueue).
29 class FifoQ {
30 public:
31  FifoQ();
32  virtual ~FifoQ();
33  double least_t();
34  void enqueue(TQItem*);
35  TQItem* dequeue();
36  void remove(TQItem*);
37  // for iteration
38  TQItem* first();
39  TQItem* next(TQItem*);
40 #if COLLECT_TQueue_STATISTICS
41 public:
42  int nfenq, nfdeq, nfrem;
43 #endif
44 private:
47 };
48 
49 class TQueue {
50 public:
51  TQueue();
52  virtual ~TQueue();
53 
54 #if FAST_LEAST
55  TQItem* least() {return least_;}
56  double least_t(){if (least_) { return least_->t_;}else{return 1e15;}}
57 #else
58  TQItem* least(); // does not remove from TQueue
59  double least_t();
60 #endif
61  TQItem* insert(double t, void* data_);
62  TQItem* insert_fifo(double t, void* data_);
63  TQItem* find(double t);
64  void remove(TQItem*);
65  void move(TQItem*, double tnew);
66  void move_least(double tnew);
67  void print();
68  void check(const char* errmess);
69  void statistics();
70  void spike_stat(double*);
71  void forall_callback(void (*)(const TQItem*, int));
72 private:
73  SPTREE* sptree_;
75  TQItem* least_;
76 #if COLLECT_TQueue_STATISTICS
77  unsigned long ninsert, nrem, nleast, nbal, ncmplxrem;
78  unsigned long ncompare, nleastsrch, nfind, nfindsrch, nmove, nfastmove;
79 #endif
80 };
81 //#endif
TQItem()
Definition: bbtqueue.cpp:3
void clear()
Definition: sptfifoq.h:18
static int first
Definition: fmenu.cpp:186
#define print
Definition: redef.h:109
Item * next(Item *item)
Definition: list.cpp:95
double t_
Definition: bbtqueue.h:18
Definition: bbtqueue.h:6
bool check()
Definition: bbtqueue.cpp:30
static double statistics(void *v)
Definition: cvodeobj.cpp:115
int nfrem
Definition: sptfifoq.h:42
virtual ~TQItem()
Definition: bbtqueue.cpp:9
static double insert(void *v)
Definition: tqueue.cpp:22
TQItem * head_
Definition: sptfifoq.h:45
virtual void move(const Event &e)
Definition: ocinput.h:19
FifoQ * fifo_
Definition: sptfifoq.h:74
TQItem * left_
Definition: bbtqueue.h:19
Definition: sptbinq.h:17
TQItem * tail_
Definition: sptfifoq.h:46
TQItem * parent_
Definition: bbtqueue.h:21
Definition: sptfifoq.h:29
static double least(void *v)
Definition: tqueue.cpp:33
int find(const int, const int, const int, const int, const int)
void * data_
Definition: bbtqueue.h:17
double t
Definition: init.cpp:123
int cnt_
Definition: spt2queue.h:23
TQItem * right_
Definition: bbtqueue.h:20
static double spike_stat(void *v)
Definition: ocbbs.cpp:693