Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
include
xbot_driver
lqueue.h
Go to the documentation of this file.
1
#ifndef LQUEUE_H
2
#define LQUEUE_H
3
#define MAX_L 100
4
#include "math.h"
5
template
<
typename
T>
6
7
class
lqueue
8
{
9
public
:
10
11
lqueue
(
int
l):
size
(0)
12
{
13
if
(l<
MAX_L
)
14
{
15
L
=l;
16
}
17
else
18
{
19
L
=
MAX_L
;
20
}
21
22
}
23
~lqueue
(){}
24
25
T
data
[
MAX_L
];
26
int
L
;
27
28
int
size
;
29
void
lpush
(T node){
30
if
(size<L)
31
{
32
*(data+
size
)=node;
33
size++;
34
}
35
else
36
{
37
for
(
int
i=0;i<
L
;i++)
38
{
39
*(data+i)=*(data+i+1);
40
}
41
*(data+L-1)=node;
42
43
}
44
45
46
}
47
bool
isImpulse
(T node){
48
if
(size == 0){
49
return
false
;
50
}
51
else
{
52
53
return
(abs(node - this->
mean
()) > 0.12*this->
mean
());
54
}
55
56
}
57
T
medium
(){
58
T tdata[
MAX_L
];
59
for
(
int
i=0;i<
size
;i++)
60
{
61
for
(
int
j=i+1;j<
size
;j++)
62
{
63
tdata[i]=(data[j]>data[i])?data[j]:data[i];
64
}
65
}
66
return
tdata[(size-1)/2];
67
}
68
T
mean
(){
69
T total=0;
70
for
(
int
i=0;i<
size
;i++)
71
{
72
total+=data[i];
73
}
74
return
total/
size
;
75
}
76
77
78
79
};
80
81
#endif
lqueue::L
int L
Definition:
lqueue.h:26
lqueue::~lqueue
~lqueue()
Definition:
lqueue.h:23
lqueue::lqueue
lqueue(int l)
Definition:
lqueue.h:11
lqueue::medium
T medium()
Definition:
lqueue.h:57
lqueue::mean
T mean()
Definition:
lqueue.h:68
lqueue::lpush
void lpush(T node)
Definition:
lqueue.h:29
lqueue::size
int size
Definition:
lqueue.h:28
MAX_L
#define MAX_L
Definition:
lqueue.h:3
lqueue::data
T data[MAX_L]
Definition:
lqueue.h:25
lqueue
Definition:
lqueue.h:7
lqueue::isImpulse
bool isImpulse(T node)
Definition:
lqueue.h:47
xbot_driver
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:27:37