File tree 1 file changed +4
-27
lines changed
src/System.Collections/src/System/Collections/Generic
1 file changed +4
-27
lines changed Original file line number Diff line number Diff line change @@ -240,40 +240,16 @@ IEnumerator IEnumerable.GetEnumerator()
240
240
// InvalidOperationException.
241
241
/// <include file='doc\Queue.uex' path='docs/doc[@for="Queue.Dequeue"]/*' />
242
242
public T Dequeue ( )
243
- {
244
- T removed ;
245
- if ( ! TryDequeue ( out removed ) )
246
- throw new InvalidOperationException ( SR . InvalidOperation_EmptyQueue ) ;
247
-
248
- return removed ;
249
- }
250
-
251
- /// <summary>
252
- /// Attempts to remove and return the object at the beginning of the <see cref="Queue{T}"/>.
253
- /// </summary>
254
- /// <param name="item">
255
- /// When this method returns, if the operation was successful, <paramref name="item"/> contains the
256
- /// object removed. If no object was available to be removed, the value is unspecified.
257
- /// </param>
258
- /// <returns>
259
- /// true if an element was removed and returned from the beginning of the <see cref="Queue{T}"/>
260
- /// successfully; otherwise, false.
261
- /// </returns>
262
- /// <include file='doc\Queue.uex' path='docs/doc[@for="Queue.TryDequeue"]/*' />
263
- public bool TryDequeue ( out T item )
264
243
{
265
244
if ( _size == 0 )
266
- {
267
- item = default ( T ) ;
268
- return false ;
269
- }
245
+ throw new InvalidOperationException ( SR . InvalidOperation_EmptyQueue ) ;
270
246
271
- item = _array [ _head ] ;
247
+ T removed = _array [ _head ] ;
272
248
_array [ _head ] = default ( T ) ;
273
249
MoveNext ( ref _head ) ;
274
250
_size -- ;
275
251
_version ++ ;
276
- return true ;
252
+ return removed ;
277
253
}
278
254
279
255
// Returns the object at the head of the queue. The object remains in the
@@ -443,6 +419,7 @@ public bool MoveNext()
443
419
444
420
arrayIndex -= capacity ; // wrap around if needed
445
421
}
422
+
446
423
_currentElement = array [ arrayIndex ] ;
447
424
return true ;
448
425
}
You can’t perform that action at this time.
0 commit comments