@@ -212,21 +212,21 @@ public void TryPeek_EmptyQueue_ShouldReturnFalseAndNull()
212212 public void PriorityOrdering_MultipleItems_ShouldMaintainCorrectOrder ( )
213213 {
214214 // Arrange
215- PriorityItem < int > [ ] items = new [ ]
216- {
215+ PriorityItem < int > [ ] items =
216+ [
217217 new PriorityItem < int > ( 5.0f , 5 ) ,
218218 new PriorityItem < int > ( 1.0f , 1 ) ,
219219 new PriorityItem < int > ( 3.0f , 3 ) ,
220220 new PriorityItem < int > ( 2.0f , 2 ) ,
221221 new PriorityItem < int > ( 4.0f , 4 )
222- } ;
222+ ] ;
223223 ConcurrentPriorityQueue < int > queue = new ( ) ;
224224
225225 // Act
226226 foreach ( PriorityItem < int > ? item in items )
227227 queue . Enqueue ( item ) ;
228228
229- List < int > results = new ( ) ;
229+ List < int > results = [ ] ;
230230 while ( ! queue . IsEmpty )
231231 results . Add ( queue . Dequeue ( ) . Item ) ;
232232
@@ -238,21 +238,21 @@ public void PriorityOrdering_MultipleItems_ShouldMaintainCorrectOrder()
238238 public void StablePriorityOrdering_SamePriorityItems_ShouldMaintainFIFOOrder ( )
239239 {
240240 // Arrange
241- PriorityItem < string > [ ] items = new [ ]
242- {
241+ PriorityItem < string > [ ] items =
242+ [
243243 new PriorityItem < string > ( 2.0f , "first" ) ,
244244 new PriorityItem < string > ( 2.0f , "second" ) ,
245245 new PriorityItem < string > ( 2.0f , "third" ) ,
246246 new PriorityItem < string > ( 1.0f , "highest" ) ,
247247 new PriorityItem < string > ( 2.0f , "fourth" )
248- } ;
248+ ] ;
249249 ConcurrentPriorityQueue < string > queue = new ( ) ;
250250
251251 // Act
252252 foreach ( PriorityItem < string > ? item in items )
253253 queue . Enqueue ( item ) ;
254254
255- List < string > results = new ( ) ;
255+ List < string > results = [ ] ;
256256 while ( ! queue . IsEmpty )
257257 results . Add ( queue . Dequeue ( ) . Item ) ;
258258
@@ -316,7 +316,7 @@ public void ConcurrentDequeue_MultipleThreads_ShouldRemoveAllItems()
316316 {
317317 // Arrange
318318 const int itemCount = 1000 ;
319- ConcurrentBag < int > dequeueResults = new ( ) ;
319+ ConcurrentBag < int > dequeueResults = [ ] ;
320320 ConcurrentPriorityQueue < int > queue = new ( ) ;
321321
322322 for ( int i = 0 ; i < itemCount ; i ++ )
@@ -325,14 +325,14 @@ public void ConcurrentDequeue_MultipleThreads_ShouldRemoveAllItems()
325325 }
326326
327327 // Act
328- Task [ ] tasks = Enumerable . Range ( 0 , 10 ) . Select ( _ => Task . Run ( ( ) =>
328+ Task [ ] tasks = [ .. Enumerable . Range ( 0 , 10 ) . Select ( _ => Task . Run ( ( ) =>
329329 {
330330 while ( queue . TryDequeue ( out PriorityItem < int > ? item ) )
331331 {
332332 dequeueResults . Add ( item . Item ) ;
333333 Thread . Sleep ( 1 ) ;
334334 }
335- } ) ) . ToArray ( ) ;
335+ } ) ) ] ;
336336
337337 Task . WaitAll ( tasks ) ;
338338
@@ -349,7 +349,7 @@ public void ConcurrentMixedOperations_MultipleThreads_ShouldMaintainConsistency(
349349 const int operationsPerThread = 50 ;
350350 ConcurrentPriorityQueue < int > queue = new ( ) ;
351351 Task [ ] tasks = new Task [ 4 ] ;
352- ConcurrentBag < Exception > exceptions = new ( ) ;
352+ ConcurrentBag < Exception > exceptions = [ ] ;
353353 using CancellationTokenSource cts = new ( TimeSpan . FromSeconds ( 10 ) ) ; // 10 second timeout
354354
355355 // Act
@@ -458,9 +458,7 @@ public void Performance_ComparedToNaiveApproach_ShouldShowImprovement()
458458 {
459459 // Arrange
460460 const int itemCount = 5000 ;
461- List < PriorityItem < int > > items = Enumerable . Range ( 0 , itemCount )
462- . Select ( i => new PriorityItem < int > ( Random . Shared . NextSingle ( ) * 1000 , i ) )
463- . ToList ( ) ;
461+ List < PriorityItem < int > > items = [ .. Enumerable . Range ( 0 , itemCount ) . Select ( i => new PriorityItem < int > ( Random . Shared . NextSingle ( ) * 1000 , i ) ) ] ;
464462
465463 // Test optimized queue
466464 ConcurrentPriorityQueue < int > optimizedQueue = new ( ) ;
@@ -476,7 +474,7 @@ public void Performance_ComparedToNaiveApproach_ShouldShowImprovement()
476474 long optimizedTime = stopwatch . ElapsedMilliseconds ;
477475
478476 // Test naive approach
479- List < PriorityItem < int > > naiveList = new ( ) ;
477+ List < PriorityItem < int > > naiveList = [ ] ;
480478 stopwatch . Restart ( ) ;
481479
482480 foreach ( PriorityItem < int > ? item in items )
@@ -585,9 +583,7 @@ public void TryRemove_NullItem_ShouldThrowArgumentNullException()
585583 public void TryRemove_RootItem_ShouldMaintainHeapProperty ( )
586584 {
587585 // Arrange
588- PriorityItem < int > [ ] items = Enumerable . Range ( 1 , 10 )
589- . Select ( i => new PriorityItem < int > ( i , i ) )
590- . ToArray ( ) ;
586+ PriorityItem < int > [ ] items = [ .. Enumerable . Range ( 1 , 10 ) . Select ( i => new PriorityItem < int > ( i , i ) ) ] ;
591587 ConcurrentPriorityQueue < int > queue = new ( ) ;
592588
593589 foreach ( PriorityItem < int > ? item in items )
@@ -629,7 +625,7 @@ public void Clear_PopulatedQueue_ShouldRemoveAllItems()
629625 public void ToArray_PopulatedQueue_ShouldReturnSortedArray ( )
630626 {
631627 // Arrange
632- float [ ] priorities = new [ ] { 5.0f , 1.0f , 3.0f , 2.0f , 4.0f } ;
628+ float [ ] priorities = [ 5.0f , 1.0f , 3.0f , 2.0f , 4.0f ] ;
633629 ConcurrentPriorityQueue < int > queue = new ( ) ;
634630
635631 for ( int i = 0 ; i < priorities . Length ; i ++ )
@@ -638,7 +634,7 @@ public void ToArray_PopulatedQueue_ShouldReturnSortedArray()
638634 }
639635
640636 // Act
641- PriorityItem < int > [ ] array = queue . ToArray ( ) ;
637+ PriorityItem < int > [ ] array = [ .. queue ] ;
642638
643639 // Assert
644640 array . Should ( ) . HaveCount ( 5 ) ;
@@ -653,7 +649,7 @@ public void ToArray_PopulatedQueue_ShouldReturnSortedArray()
653649 public void ToArray_EmptyQueue_ShouldReturnEmptyArray ( )
654650 {
655651 // Act
656- PriorityItem < string > [ ] array = _queue . ToArray ( ) ;
652+ PriorityItem < string > [ ] array = [ .. _queue ] ;
657653
658654 // Assert
659655 array . Should ( ) . BeEmpty ( ) ;
@@ -690,18 +686,18 @@ public void IsValidQueue_AlwaysTrue_ForProperlyMaintainedHeap()
690686 public void GetEnumerator_PopulatedQueue_ShouldReturnAllItems ( )
691687 {
692688 // Arrange
693- PriorityItem < string > [ ] items = new [ ]
694- {
689+ PriorityItem < string > [ ] items =
690+ [
695691 new PriorityItem < string > ( 1.0f , "first" ) ,
696692 new PriorityItem < string > ( 2.0f , "second" ) ,
697693 new PriorityItem < string > ( 3.0f , "third" )
698- } ;
694+ ] ;
699695
700696 foreach ( PriorityItem < string > ? item in items )
701697 _queue . Enqueue ( item ) ;
702698
703699 // Act
704- List < PriorityItem < string > > enumeratedItems = _queue . ToList ( ) ;
700+ List < PriorityItem < string > > enumeratedItems = [ .. _queue ] ;
705701
706702 // Assert
707703 enumeratedItems . Should ( ) . HaveCount ( 3 ) ;
@@ -715,7 +711,7 @@ public void GetEnumerator_PopulatedQueue_ShouldReturnAllItems()
715711 public void GetEnumerator_EmptyQueue_ShouldReturnNoItems ( )
716712 {
717713 // Act
718- List < PriorityItem < string > > enumeratedItems = _queue . ToList ( ) ;
714+ List < PriorityItem < string > > enumeratedItems = [ .. _queue ] ;
719715
720716 // Assert
721717 enumeratedItems . Should ( ) . BeEmpty ( ) ;
@@ -732,7 +728,7 @@ public void GetEnumerator_ConcurrentModification_ShouldReflectLiveState()
732728 IEnumerator < PriorityItem < string > > enumerator = _queue . GetEnumerator ( ) ;
733729 PriorityItem < string > item2 = new ( 2.0f , "test2" ) ;
734730 _queue . Enqueue ( item2 ) ;
735- List < PriorityItem < string > > items = new ( ) ;
731+ List < PriorityItem < string > > items = [ ] ;
736732
737733 while ( enumerator . MoveNext ( ) )
738734 {
0 commit comments