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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Misc
{
//
public class RList<T>:List<T>
{
int tailer_no;//尾部对应的编号,每个数据,有唯一的编号。当是环状数组,数据会被覆盖,编号就会对应不上序号。序号一定可以转为编号
int cap;
public RList(int cap):base(cap)
{
this.cap = cap;
tailer_no = 0;
}
public T RAdd(T dat)
{
Add(dat);
tailer_no++;
T ret = default(T);
if (Count > cap)
{
ret = this.ElementAt(0);
RemoveAt(0);
}
return ret;
}
public T[] ToArray(int index, int count)
{
return GetRange(index, count).ToArray();
}
public int Index2No(int index)
{
return index - (this.Count - 1) + tailer_no;
}
public int No2Index(int no)
{
int index = no - tailer_no + (this.Count - 1);
return index;
}
public int GetLastNo()
{
return tailer_no;
}
}
}