OSDN Git Service

indent.
[tdcgexplorer/tso2mqo.git] / Heap.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Text;
4
5 namespace Tso2MqoGui
6 {
7     public class Heap<T>
8     {
9         public Dictionary<T, ushort> map = new Dictionary<T, ushort>();
10         public List<T> ary = new List<T>();
11
12         public void Clear()
13         {
14             map.Clear();
15             ary.Clear();
16         }
17
18         public ushort Add(T v)
19         {
20             ushort n;
21
22             if (map.TryGetValue(v, out n))
23                 return n;
24
25             n = (ushort)ary.Count;
26             map.Add(v, n);
27             ary.Add(v);
28             return n;
29         }
30
31         public int Count { get { return ary.Count; } }
32         public ushort this[T index] { get { return map[index]; } }
33     }
34 }