summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XUtliPoolLib/QuestionLibraryTable.cs
blob: 587e04e1b1b581d83d802a51aadb903b26582620 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
using System;

namespace XUtliPoolLib
{
	public class QuestionLibraryTable : CVSReader
	{
		public QuestionLibraryTable.RowData[] Table = null;

		public class RowData
		{
			public int ID;

			public string Question;

			public int TimeLimit;

			public uint Week;
		}

		public QuestionLibraryTable.RowData GetByID(int key)
		{
			bool flag = this.Table == null || this.Table.Length == 0;
			QuestionLibraryTable.RowData result;
			if (flag)
			{
				result = null;
			}
			else
			{
				result = this.BinarySearchID(key);
			}
			return result;
		}

		private QuestionLibraryTable.RowData BinarySearchID(int key)
		{
			int num = 0;
			int num2 = this.Table.Length - 1;
			QuestionLibraryTable.RowData rowData;
			QuestionLibraryTable.RowData rowData2;
			QuestionLibraryTable.RowData rowData3;
			for (;;)
			{
				rowData = this.Table[num];
				bool flag = rowData.ID == key;
				if (flag)
				{
					break;
				}
				rowData2 = this.Table[num2];
				bool flag2 = rowData2.ID == key;
				if (flag2)
				{
					goto Block_2;
				}
				bool flag3 = num2 - num <= 1;
				if (flag3)
				{
					goto Block_3;
				}
				int num3 = num + (num2 - num) / 2;
				rowData3 = this.Table[num3];
				bool flag4 = rowData3.ID.CompareTo(key) > 0;
				if (flag4)
				{
					num2 = num3;
				}
				else
				{
					bool flag5 = rowData3.ID.CompareTo(key) < 0;
					if (!flag5)
					{
						goto IL_B1;
					}
					num = num3;
				}
				if (num >= num2)
				{
					goto Block_6;
				}
			}
			return rowData;
			Block_2:
			return rowData2;
			Block_3:
			return null;
			IL_B1:
			return rowData3;
			Block_6:
			return null;
		}

		protected override void ReadLine(XBinaryReader reader)
		{
			QuestionLibraryTable.RowData rowData = new QuestionLibraryTable.RowData();
			base.Read<int>(reader, ref rowData.ID, CVSReader.intParse);
			this.columnno = 0;
			base.Read<string>(reader, ref rowData.Question, CVSReader.stringParse);
			this.columnno = 2;
			base.Read<int>(reader, ref rowData.TimeLimit, CVSReader.intParse);
			this.columnno = 4;
			base.Read<uint>(reader, ref rowData.Week, CVSReader.uintParse);
			this.columnno = 7;
			this.Table[this.lineno] = rowData;
			this.columnno = -1;
		}

		protected override void OnClear(int lineCount)
		{
			bool flag = lineCount > 0;
			if (flag)
			{
				this.Table = new QuestionLibraryTable.RowData[lineCount];
			}
			else
			{
				this.Table = null;
			}
		}
	}
}