-
Notifications
You must be signed in to change notification settings - Fork 0
/
biteiroQueue.h
65 lines (58 loc) · 2.23 KB
/
biteiroQueue.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <float.h>
#include <math.h>
#include <string.h>
#include <assert.h>
#define SANNITY_CHECK_VALUE 0X5A6596A5
#define MAX_BUFFER_QUEUE_LENGHT 1000
#define MAX_BUFFER_QUEUE_IDENTITY 512
#define INTERNAL_MAX_KEY_LEN 12
typedef struct st_bitQueue_Statistics {
size_t keyLen;
size_t maxKeyLen;
long pkey[INTERNAL_MAX_KEY_LEN]; // Key used to search patterns
size_t bufferLen;
size_t queueLen;
size_t qtItens; // Quantity of itens inserted in pbufferList
size_t qtOrder; // Quantity of ordered list in psortedList. Must be the same value of qtItens
size_t indxNextHead;
size_t indxNextTail;
size_t indxGet;
size_t indxPut;
double hurstValue; // This is the hurst number. (Remember 0 ==> is Alternance; 1 ==> is Assertivity; 0.5 ==> is Random )
double _R_S; // This is the confiability factor of hurst
long _upperLimitValue;
long _lowerLimitValue;
long sum;
long maxValue;
long minValue;
long maxValueBackup; // To speed up return of max values
long minValueBackup; // To speed up return of min values
long lastValue; // This is the last value inserted.
long medianValue; // This is the tendency value or the midle value.
double meanHurst; // This is the average used by hurst calculus.
long modeValue; // equals to puniqueList[0]
size_t *prankList; // rankList and uniqueList will work together
long *puniqueList; // This list will order by rankList
long *psortedList; // Used to calculate median value.
long *pbufferList; // The real data is here.
} bitQUEUE;
#if defined BITEIRO_QUEUE_C
#define EXTERN
#elif defined CPP_CODE
#define EXTERN extern "C"
#else
#define EXTERN extern
#endif
EXTERN bitQUEUE *bitQ_alloc(size_t buf_len, size_t queue_len, size_t p_keyLen, long p_min, long p_max);
EXTERN int bitQ_free(bitQUEUE *);
EXTERN long bitQ_remove(bitQUEUE *pbq, bool tail);
EXTERN long bitQ_insert(bitQUEUE *pbq, long value, bool tail);
EXTERN void bitQ_printAllItens(bitQUEUE *pq);
EXTERN void bitQ_printUniqueItens(bitQUEUE *pq);
EXTERN void bitQ_printRankValues(bitQUEUE *pq);
EXTERN void bitQ_showStatistics(bitQUEUE *pq, bool onlyLast);
EXTERN int testBiteiroQueue(int argc, char ** argv);
#undef EXTERN