-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcorrelationBasket.cpp
97 lines (81 loc) · 1.92 KB
/
correlationBasket.cpp
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//Stephen
#include "correlationBasket.h"
CorrelationBasket::CorrelationBasket()
{
mSize = 0;
mMinOccurance = 0;
}
CorrelationBasket::CorrelationBasket(int newSize)
{
mSize = newSize;
Correlation *mCorrelations = new Correlation[mSize];
}
CorrelationBasket::~CorrelationBasket()
{
}
//populates a new basket with the relevant correlations from the previous basket
void CorrelationBasket::populate (CorrelationBasket otherBasket)
{
Correlation *tmpList = new Correlation[mSize]; //tmp list to copy relevant transactions
int tmpSize = 0; //keeps track of new transactions to determine new size
//fill temp list
for (int i = 0; i < mSize; i++)
{
if (otherBasket.getCorrelation(i).getRelevant() == true)
{
tmpList[tmpSize] = otherBasket.getCorrelation(i);
tmpSize++;
}
}
//populate actual list
for (int j = 0; j < tmpSize; j++)
{
mCorrelations[j] = tmpList[j];
}
mSize = tmpSize;
}
//goes through all correlations and updates their relevance by Gabe
void CorrelationBasket::updateRelevance()
{
for (int i = 0; i < mSize; i++)
{
if (mCorrelations[i].getOccurance() < mMinOccurance)
{
mCorrelations[i].setRelevant(false);
}
}
}
int CorrelationBasket::getSize()
{
return mSize;
}
void CorrelationBasket::setSize(int size)
{
mSize = size;
}
int CorrelationBasket::getMinOccurance()
{
return mMinOccurance;
}
void CorrelationBasket::setMinOccurance(int occurance)
{
mMinOccurance = occurance;
}
Correlation& CorrelationBasket::getCorrelation(int choice)
{
return mCorrelations[choice];
}
void CorrelationBasket::setCorrelation(Correlation &newCore, int choice)
{
mCorrelations[choice] = newCore;
mSize++;
}
void CorrelationBasket::operator= (CorrelationBasket &rhs)
{
mMinOccurance = rhs.getMinOccurance();
mSize = rhs.getSize();
for (int i = 0; i < mSize; i++)
{
mCorrelations[i] = rhs.getCorrelation(i);
}
}