回答編集履歴
2
別解追記
test
CHANGED
@@ -42,10 +42,88 @@
|
|
42
42
|
|
43
43
|
}
|
44
44
|
|
45
|
+
```
|
45
46
|
|
46
47
|
|
47
48
|
|
48
49
|
|
49
50
|
|
51
|
+
別解
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
```csharp
|
56
|
+
|
57
|
+
using System.Linq;
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
public class TestClass
|
62
|
+
|
63
|
+
{
|
64
|
+
|
65
|
+
public int Value;
|
66
|
+
|
67
|
+
public string Name;
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
List<TestClass> list = new List<TestClass>();
|
72
|
+
|
73
|
+
List<TestClass> updatedElements = new List<TestClass>();
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
void InitList()
|
78
|
+
|
79
|
+
{
|
80
|
+
|
81
|
+
for (int i = 0; i < 100; i++)
|
82
|
+
|
83
|
+
{
|
84
|
+
|
85
|
+
TestClass t = new TestClass { value = i, name = i.ToString() };
|
86
|
+
|
87
|
+
list.Add(t);
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
// リストの最初の50個を更新
|
94
|
+
|
95
|
+
int index;
|
96
|
+
|
97
|
+
for (index = 0; index < 50; index++)
|
98
|
+
|
99
|
+
{
|
100
|
+
|
101
|
+
UpdateList(index);
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
list = updatedElements.OrderBy(e => e.Value).ToList();
|
108
|
+
|
109
|
+
updatedElement.Clear();
|
110
|
+
|
111
|
+
}
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
void UpdateList(int index)
|
116
|
+
|
117
|
+
{
|
118
|
+
|
119
|
+
// 質問と同じ実装する
|
120
|
+
|
121
|
+
TestClass updatedElement = ...// 質問と同じ内容を実装し、更新された要素を保持
|
122
|
+
|
123
|
+
updatedElements.Add(updatedElement);
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
50
128
|
|
51
129
|
```
|
1
update
test
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
```
|
9
|
+
```csharp
|
10
10
|
|
11
11
|
using System.Linq;
|
12
12
|
|