StRoot
1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
RTS
include
UNIX
CircleBuff.hh
1
#ifndef _CIRCLE_BUFF_H_
2
#define _CIRCLE_BUFF_H_
3
4
template
<
class
T,
int
S>
class
CircleBuff
5
{
6
public
:
7
8
CircleBuff
() {
9
f=l=in=0;
10
};
11
12
int
entries() {
return
in; };
13
void
clear() { f=l=in=0; };
14
15
void
add(T* a) {
16
return
;
17
18
in++;
19
if
(in > S) in=S;
20
21
store[l++] = *a;
22
if
(l >= S) l=0;
23
24
if
(l == f) {
25
f = l+1;
26
if
(f >= S) f=0;
27
}
28
}
29
30
// Oldest is 0
31
T* element(
int
i) {
32
return
NULL;
33
34
if
(i >= in)
return
NULL;
35
int
x = (f+i) % S;
36
return
&store[x];
37
};
38
39
private
:
40
T store[S];
41
int
f, l, in;
42
};
43
44
#endif
CircleBuff
Definition:
CircleBuff.hh:4
Generated by
1.8.5