@@ -9,25 +9,22 @@ namespace WattleScript.Interpreter.DataStructs
9
9
/// Provides facility to create a "sliced" view over an existing IList<typeparamref name="T"/>
10
10
/// </summary>
11
11
/// <typeparam name="T">The type of the items contained in the collection</typeparam>
12
- internal class Slice < T > : IEnumerable < T > , IList < T >
12
+ internal class Slice < T > : IList < T >
13
13
{
14
14
IList < T > m_SourceList ;
15
15
int m_From , m_Length ;
16
- bool m_Reversed ;
17
16
18
17
/// <summary>
19
18
/// Initializes a new instance of the <see cref="Slice{T}"/> class.
20
19
/// </summary>
21
20
/// <param name="list">The list to apply the Slice view on</param>
22
21
/// <param name="from">From which index</param>
23
22
/// <param name="length">The length of the slice</param>
24
- /// <param name="reversed">if set to <c>true</c> the view is in reversed order.</param>
25
- public Slice ( IList < T > list , int from , int length , bool reversed )
23
+ public Slice ( IList < T > list , int from , int length )
26
24
{
27
25
m_SourceList = list ;
28
26
m_From = from ;
29
27
m_Length = length ;
30
- m_Reversed = reversed ;
31
28
}
32
29
33
30
/// <summary>
@@ -37,60 +34,36 @@ public Slice(IList<T> list, int from, int length, bool reversed)
37
34
/// <returns></returns>
38
35
public T this [ int index ]
39
36
{
40
- get
41
- {
42
- return m_SourceList [ CalcRealIndex ( index ) ] ;
43
- }
44
- set
45
- {
46
- m_SourceList [ CalcRealIndex ( index ) ] = value ;
47
- }
37
+ get => m_SourceList [ CalcRealIndex ( index ) ] ;
38
+ set => m_SourceList [ CalcRealIndex ( index ) ] = value ;
48
39
}
49
40
50
41
/// <summary>
51
42
/// Gets the index from which the slice starts
52
43
/// </summary>
53
- public int From
54
- {
55
- get { return m_From ; }
56
- }
44
+ public int From => m_From ;
57
45
58
46
/// <summary>
59
47
/// Gets the number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.
60
48
/// </summary>
61
49
/// <returns>The number of elements contained in the <see cref="T:System.Collections.Generic.ICollection`1" />.</returns>
62
- public int Count
63
- {
64
- get { return m_Length ; }
65
- }
66
-
50
+ public int Count => m_Length ;
51
+
67
52
/// <summary>
68
- /// Gets a value indicating whether this <see cref="Slice{T}" /> operates in a reversed direction .
53
+ /// Gets a value indicating whether the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only .
69
54
/// </summary>
70
- /// <value>
71
- /// <c>true</c> if this <see cref="Slice{T}"/> operates in a reversed direction; otherwise, <c>false</c>.
72
- /// </value>
73
- public bool Reversed
74
- {
75
- get { return m_Reversed ; }
76
- }
77
-
55
+ /// <returns>true if the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only; otherwise, false.</returns>
56
+ public bool IsReadOnly => true ;
57
+
78
58
/// <summary>
79
59
/// Calculates the real index in the underlying collection
80
60
/// </summary>
81
61
private int CalcRealIndex ( int index )
82
62
{
83
63
if ( index < 0 || index >= m_Length )
84
- throw new ArgumentOutOfRangeException ( "index" ) ;
85
-
86
- if ( m_Reversed )
87
- {
88
- return m_From + m_Length - index - 1 ;
89
- }
90
- else
91
- {
92
- return m_From + index ;
93
- }
64
+ throw new ArgumentOutOfRangeException ( nameof ( index ) ) ;
65
+
66
+ return m_From + index ;
94
67
}
95
68
96
69
/// <summary>
@@ -224,15 +197,6 @@ public void CopyTo(T[] array, int arrayIndex)
224
197
array [ i + arrayIndex ] = this [ i ] ;
225
198
}
226
199
227
- /// <summary>
228
- /// Gets a value indicating whether the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only.
229
- /// </summary>
230
- /// <returns>true if the <see cref="T:System.Collections.Generic.ICollection`1" /> is read-only; otherwise, false.</returns>
231
- public bool IsReadOnly
232
- {
233
- get { return true ; }
234
- }
235
-
236
200
/// <summary>
237
201
/// Removes the first occurrence of a specific object from the <see cref="T:System.Collections.Generic.ICollection`1" />.
238
202
/// </summary>
0 commit comments