-
Notifications
You must be signed in to change notification settings - Fork 7
/
Share.cpp
60 lines (51 loc) · 1.19 KB
/
Share.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
#include "Individual.h"
Share::Share( Individual * cip )
{
add( cip );
}
unsigned int Share::size()
{
return matches.size();
}
void Share::assertMatches()
{
list<Individual*>::iterator i , ii;
Match * m;
for ( i = matches.begin() ; i != matches.end() ; i++ )
{
ii = i;
for ( ++ii ; ii != matches.end() ; ii++ )
{
// Check if this pair matched in previous word (symmetrically)
m = (*i)->getMatch( (*ii)->getNumericID() );
if ( m == NULL ) m = (*ii)->getMatch( (*i)->getNumericID() );
if ( m != NULL )
{
// This match can be incremented
m->end_ms = position_ms;
}
else
{
// This match must be created
m = createMatch( *i , *ii );
// Extend the match backwards
m->extendBack();
// Mark asserted
(*i)->addMatch( (*ii)->getNumericID() , m );
}
}
}
}
Match * Share::createMatch(Individual * c1 , Individual * c2)
{
Match * new_match = new Match();
new_match->end_ms = new_match->start_ms = position_ms;
new_match->node[0] = c1;
new_match->node[1] = c2;
mem_all_matches+= sizeof(Match);
return new_match;
}
void Share::add(Individual * cip)
{
matches.push_back( cip );
}