blob: 79bf893a000eb53bf61d76cbdf597c151994aa33 (
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
|
using System;
using System.Collections;
using System.Collections.Specialized;
public class List : IEnumerable {
int pos = 0;
int [] items;
public List (int i)
{
items = new int [i];
}
public void Add (int value)
{
items [pos ++] = value;
}
public MyEnumerator GetEnumerator ()
{
return new MyEnumerator(this);
}
IEnumerator IEnumerable.GetEnumerator ()
{
return GetEnumerator ();
}
public struct MyEnumerator : IEnumerator {
List l;
int p;
public MyEnumerator (List l)
{
this.l = l;
p = -1;
}
public object Current {
get {
return l.items [p];
}
}
public bool MoveNext()
{
return ++p < l.pos;
}
public void Reset()
{
p = 0;
}
}
}
public class UberList : List {
public UberList (int i) : base (i)
{
}
public static int Main(string[] args)
{
return One () && Two () && Three () ? 0 : 1;
}
static bool One ()
{
List l = new List (1);
l.Add (1);
foreach (int i in l)
if (i == 1)
return true;
return false;
}
static bool Two ()
{
List l = new UberList (1);
l.Add (1);
foreach (int i in l)
if (i == 1)
return true;
return false;
}
static bool Three ()
{
UberList l = new UberList (1);
l.Add (1);
foreach (int i in l)
if (i == 1)
return true;
return false;
}
}
|