-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPool.cs
48 lines (39 loc) · 1.16 KB
/
Pool.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp3
{
class Pool
{
public List<Agent> Agents { get; set; }
public Dictionary<Agent, Agent> Solution { get; set; }
public bool Empty { get { return Agents.Count == 0; } }
public Pool(List<Agent> agents)
{
Agents = agents;
Solution = new Dictionary<Agent, Agent>();
}
public void Update()
{
Agents.RemoveAll(i => i.PreferenceList.Count == 0);
}
public void Match(Agent a1, Agent a2)
{
Solution.Add(a1, a2);
Solution.Add(a2, a1);
Agents.Remove(a1);
Agents.Remove(a2);
}
public void MatchCycle(List<Agent> coreCycle)
{
if (coreCycle.Count >= 2)
{
Solution.Add(coreCycle.Last(), coreCycle.First());
for (int i = 0; i < coreCycle.Count -1; i++)
Solution.Add(coreCycle[i], coreCycle[i + 1]);
}
}
}
}