-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpriority.h
64 lines (59 loc) · 1.68 KB
/
priority.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
#ifndef run
#include <bits/stdc++.h>
using namespace std;
#include "Parameter.h"
#include "String.h"
#include "Expression.h"
#include "Keyword.h"
#include "Mail.h"
#include "Heap.h"
#include "Order_Tree.h"
#endif
class Priority{
vector <string> people ;
vector <string> password ;
double People , Password , Date ;
Heap<MAX_MAIL, double> list;
public:
void init(){
string line , split , query , query_index ;
ifstream file ;
file.open(".priority_conf", ios::in);
getline ( file , line ) ;
stringstream is( line ) ;
while( is >> split ) people.push_back(split) ;
getline ( file , line ) ;
stringstream is2( line ) ;
while( is2 >> split ) password.push_back(split) ;
getline ( file , line ) ;
stringstream is3( line ) ;
for(int i = 0 ; i < 3 ; ++i ){
double x;
is3 >> x;
if( i == 0 ) People = x ;
else if ( i == 1 ) Password = x ;
else Date = x ;
}
file.close() ;
}
/*void build(){
#}*/
void insert(Mail &M) {
double value , PEOPLE = 0 , PASSWD = 0 , DATE = 0 ;
for (int i = 0 ; i < int(people.size()) ; ++i ) {
if( M.keyword.match(people[i])) PEOPLE = 110./(i+1) - 100. ;
}
for (int i = 0 ; i < int(password.size()) ; ++i ) {
if( M.keyword.match(password[i])) PASSWD += 110./(i+1) - 100.;
}
DATE = (double)M.date/20000000 ;
value = People * PEOPLE + Password * PASSWD + Date * DATE ;
list.push( value , M.id );
}
void erase(int id) {
list.erase(id) ;
}
vector<int> query(int k) {
return list.kth(k);
}
};