This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +2
-15
lines changed
src/System.Collections/src/System/Collections/Generic Expand file tree Collapse file tree 2 files changed +2
-15
lines changed Original file line number Diff line number Diff line change @@ -32,14 +32,13 @@ public class Queue<T> : IEnumerable<T>,
32
32
private const int MinimumGrow = 4 ;
33
33
private const int GrowFactor = 200 ; // double each time
34
34
private const int DefaultCapacity = 4 ;
35
- private static T [ ] s_emptyArray = Array . Empty < T > ( ) ;
36
35
37
36
// Creates a queue with room for capacity objects. The default initial
38
37
// capacity and grow factor are used.
39
38
/// <include file='doc\Queue.uex' path='docs/doc[@for="Queue.Queue"]/*' />
40
39
public Queue ( )
41
40
{
42
- _array = s_emptyArray ;
41
+ _array = Array . Empty < T > ( ) ;
43
42
}
44
43
45
44
// Creates a queue with room for capacity objects. The default grow factor
@@ -50,11 +49,7 @@ public Queue(int capacity)
50
49
{
51
50
if ( capacity < 0 )
52
51
throw new ArgumentOutOfRangeException ( "capacity" , SR . ArgumentOutOfRange_NeedNonNegNumRequired ) ;
53
-
54
52
_array = new T [ capacity ] ;
55
- _head = 0 ;
56
- _tail = 0 ;
57
- _size = 0 ;
58
53
}
59
54
60
55
// Fills a Queue with the elements of an ICollection. Uses the enumerator
@@ -67,8 +62,6 @@ public Queue(IEnumerable<T> collection)
67
62
throw new ArgumentNullException ( "collection" ) ;
68
63
69
64
_array = new T [ DefaultCapacity ] ;
70
- _size = 0 ;
71
- _version = 0 ;
72
65
73
66
using ( IEnumerator < T > en = collection . GetEnumerator ( ) )
74
67
{
Original file line number Diff line number Diff line change @@ -29,14 +29,11 @@ public class Stack<T> : IEnumerable<T>,
29
29
private Object _syncRoot ;
30
30
31
31
private const int DefaultCapacity = 4 ;
32
- private static T [ ] s_emptyArray = Array . Empty < T > ( ) ;
33
32
34
33
/// <include file='doc\Stack.uex' path='docs/doc[@for="Stack.Stack"]/*' />
35
34
public Stack ( )
36
35
{
37
- _array = s_emptyArray ;
38
- _size = 0 ;
39
- _version = 0 ;
36
+ _array = Array . Empty < T > ( ) ;
40
37
}
41
38
42
39
// Create a stack with a specific initial capacity. The initial capacity
@@ -47,8 +44,6 @@ public Stack(int capacity)
47
44
if ( capacity < 0 )
48
45
throw new ArgumentOutOfRangeException ( "capacity" , SR . ArgumentOutOfRange_NeedNonNegNumRequired ) ;
49
46
_array = new T [ capacity ] ;
50
- _size = 0 ;
51
- _version = 0 ;
52
47
}
53
48
54
49
// Fills a Stack with the contents of a particular collection. The items are
@@ -59,7 +54,6 @@ public Stack(IEnumerable<T> collection)
59
54
{
60
55
if ( collection == null )
61
56
throw new ArgumentNullException ( "collection" ) ;
62
-
63
57
_array = EnumerableHelpers . ToArray ( collection , out _size ) ;
64
58
}
65
59
You can’t perform that action at this time.
0 commit comments