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 
20  public:
21  void* data_;
22  double t_;
23  TQItem* left_; // in the fifo, this is toward the head
24  TQItem* right_; // in the fifo, this is toward the tail
25  TQItem* parent_; // in the fifo, this is unused
26  int cnt_; // reused: -1 means it is in the fifo
27 };
28 
29 // helper class for the TQueue (SplayTFifoQueue).
30 class FifoQ {
31  public:
32  FifoQ();
33  virtual ~FifoQ();
34  double least_t();
35  void enqueue(TQItem*);
36  TQItem* dequeue();
37  void remove(TQItem*);
38  // for iteration
39  TQItem* first();
40  TQItem* next(TQItem*);
41 #if COLLECT_TQueue_STATISTICS
42  public:
43  int nfenq, nfdeq, nfrem;
44 #endif
45  private:
48 };
49 
50 class TQueue {
51  public:
52  TQueue();
53  virtual ~TQueue();
54 
55 #if FAST_LEAST
56  TQItem* least() {
57  return least_;
58  }
59  double least_t() {
60  if (least_) {
61  return least_->t_;
62  } else {
63  return 1e15;
64  }
65  }
66 #else
67  TQItem* least(); // does not remove from TQueue
68  double least_t();
69 #endif
70  TQItem* insert(double t, void* data_);
71  TQItem* insert_fifo(double t, void* data_);
72  TQItem* find(double t);
73  void remove(TQItem*);
74  void move(TQItem*, double tnew);
75  void move_least(double tnew);
76  void print();
77  void check(const char* errmess);
78  void statistics();
79  void spike_stat(double*);
80  void forall_callback(void (*)(const TQItem*, int));
81 
82  private:
83  SPTREE* sptree_;
85  TQItem* least_;
86 #if COLLECT_TQueue_STATISTICS
87  unsigned long ninsert, nrem, nleast, nbal, ncmplxrem;
88  unsigned long ncompare, nleastsrch, nfind, nfindsrch, nmove, nfastmove;
89 #endif
90 };
91 //#endif
Definition: sptfifoq.h:30
void enqueue(TQItem *)
Definition: sptfifoq.cpp:258
int nfrem
Definition: sptfifoq.h:43
TQItem * head_
Definition: sptfifoq.h:46
TQItem * dequeue()
Definition: sptfifoq.cpp:275
FifoQ()
Definition: sptfifoq.cpp:241
int nfdeq
Definition: sptfifoq.h:43
virtual ~FifoQ()
Definition: sptfifoq.cpp:248
TQItem * tail_
Definition: sptfifoq.h:47
int nfenq
Definition: sptfifoq.h:43
TQItem * first()
Definition: sptfifoq.cpp:313
double least_t()
Definition: sptfifoq.cpp:252
TQItem * next(TQItem *)
Definition: sptfifoq.cpp:316
void remove(TQItem *)
Definition: sptfifoq.cpp:292
Definition: bbtqueue.h:6
virtual ~TQItem()
void clear()
Definition: sptfifoq.h:18
double t_
Definition: bbtqueue.h:23
bool check()
TQItem * right_
Definition: bbtqueue.h:25
int cnt_
Definition: spt2queue.h:24
TQItem * parent_
Definition: bbtqueue.h:26
TQItem * left_
Definition: bbtqueue.h:24
void * data_
Definition: bbtqueue.h:22
unsigned long nbal
Definition: bbtqueue.h:58
void statistics()
unsigned long nleastsrch
Definition: bbtqueue.h:59
void remove(TQItem *)
TQItem * insert_fifo(double t, void *data_)
double least_t()
Definition: bbtqueue.cpp:131
TQItem * least()
Definition: bbtqueue.cpp:140
void check(const char *errmess)
virtual ~TQueue()
TQItem * least()
void move(TQItem *, double tnew)
unsigned long nmove
Definition: bbtqueue.h:59
TQItem * least_
Definition: bbtqueue.h:54
unsigned long ninsert
Definition: bbtqueue.h:58
void print()
unsigned long nrem
Definition: bbtqueue.h:58
TQItem * insert(double t, void *data_)
FifoQ * fifo_
Definition: sptfifoq.h:84
unsigned long nfastmove
Definition: bbtqueue.h:59
SPTREE * sptree_
Definition: spt2queue.h:61
TQItem * find(double t)
unsigned long nfindsrch
Definition: bbtqueue.h:59
unsigned long ncompare
Definition: bbtqueue.h:59
unsigned long nleast
Definition: bbtqueue.h:58
unsigned long nfind
Definition: bbtqueue.h:59
unsigned long ncmplxrem
Definition: bbtqueue.h:58
void forall_callback(void(*)(const TQItem *, int))
void move_least(double tnew)
void spike_stat(double *)
double t
Definition: cvodeobj.cpp:59
Definition: sptree.h:40