1
1
#pragma warning disable CS9074
2
+ #nullable enable
2
3
3
4
using System ;
4
5
using System . ComponentModel ;
@@ -12,24 +13,6 @@ namespace ZLinq
12
13
{
13
14
public static class UnityCollectionsExtensions
14
15
{
15
- public static ValueEnumerable < FromNativeArray < T > , T > AsValueEnumerable < T > ( this NativeArray < T > source )
16
- where T : struct
17
- {
18
- return new ( new ( source . AsReadOnly ( ) ) ) ;
19
- }
20
-
21
- public static ValueEnumerable < FromNativeArray < T > , T > AsValueEnumerable < T > ( this NativeArray < T > . ReadOnly source )
22
- where T : struct
23
- {
24
- return new ( new ( source ) ) ;
25
- }
26
-
27
- public static ValueEnumerable < FromNativeSlice < T > , T > AsValueEnumerable < T > ( this NativeSlice < T > source )
28
- where T : struct
29
- {
30
- return new ( new ( source ) ) ;
31
- }
32
-
33
16
#if ZLINQ_UNITY_COLLECTIONS_SUPPORT
34
17
public static ValueEnumerable < FromNativeList < T > , T > AsValueEnumerable < T > ( this NativeList < T > source )
35
18
where T : unmanaged
@@ -136,112 +119,6 @@ public static ValueEnumerable<FromFixedList4096Bytes<T>, T> AsValueEnumerable<T>
136
119
#endif
137
120
}
138
121
139
- [ StructLayout ( LayoutKind . Auto ) ]
140
- [ EditorBrowsable ( EditorBrowsableState . Never ) ]
141
- public struct FromNativeArray < T > : IValueEnumerator < T >
142
- where T : struct
143
- {
144
- public FromNativeArray ( NativeArray < T > . ReadOnly source )
145
- {
146
- this . source = source ;
147
- this . index = 0 ;
148
- }
149
-
150
- NativeArray < T > . ReadOnly source ;
151
- int index ;
152
-
153
- public void Dispose ( )
154
- {
155
- }
156
-
157
- public bool TryCopyTo ( Span < T > destination , Index offset )
158
- {
159
- if ( EnumeratorHelper . TryGetSlice < T > ( source , offset , destination . Length , out var slice ) )
160
- {
161
- slice . CopyTo ( destination ) ;
162
- return true ;
163
- }
164
- return false ;
165
- }
166
-
167
- public bool TryGetNext ( out T current )
168
- {
169
- if ( index < source . Length )
170
- {
171
- current = source [ index ++ ] ;
172
- return true ;
173
- }
174
-
175
- Unsafe . SkipInit ( out current ) ;
176
- return false ;
177
- }
178
-
179
- public bool TryGetNonEnumeratedCount ( out int count )
180
- {
181
- count = source . Length ;
182
- return true ;
183
- }
184
-
185
- public bool TryGetSpan ( out ReadOnlySpan < T > span )
186
- {
187
- span = source ;
188
- return true ;
189
- }
190
- }
191
-
192
- [ StructLayout ( LayoutKind . Auto ) ]
193
- [ EditorBrowsable ( EditorBrowsableState . Never ) ]
194
- public struct FromNativeSlice < T > : IValueEnumerator < T >
195
- where T : struct
196
- {
197
- NativeSlice < T > source ;
198
- int index ;
199
-
200
- public FromNativeSlice ( NativeSlice < T > source )
201
- {
202
- this . source = source ;
203
- this . index = 0 ;
204
- }
205
-
206
- public void Dispose ( )
207
- {
208
- }
209
-
210
- public unsafe bool TryCopyTo ( Span < T > destination , Index offset )
211
- {
212
- if ( EnumeratorHelper . TryGetSlice ( new ReadOnlySpan < T > ( source . GetUnsafePtr ( ) , source . Length ) , offset , destination . Length , out var slice ) )
213
- {
214
- slice . CopyTo ( destination ) ;
215
- return true ;
216
- }
217
- return false ;
218
- }
219
-
220
- public bool TryGetNext ( out T current )
221
- {
222
- if ( index < source . Length )
223
- {
224
- current = source [ index ++ ] ;
225
- return true ;
226
- }
227
-
228
- Unsafe . SkipInit ( out current ) ;
229
- return false ;
230
- }
231
-
232
- public bool TryGetNonEnumeratedCount ( out int count )
233
- {
234
- count = source . Length ;
235
- return true ;
236
- }
237
-
238
- public unsafe bool TryGetSpan ( out ReadOnlySpan < T > span )
239
- {
240
- span = new ReadOnlySpan < T > ( source . GetUnsafePtr ( ) , source . Length ) ;
241
- return true ;
242
- }
243
- }
244
-
245
122
#if ZLINQ_UNITY_COLLECTIONS_SUPPORT
246
123
[ StructLayout ( LayoutKind . Auto ) ]
247
124
[ EditorBrowsable ( EditorBrowsableState . Never ) ]
@@ -279,7 +156,7 @@ public bool TryGetNext(out T current)
279
156
return true ;
280
157
}
281
158
282
- Unsafe . SkipInit ( out current ) ;
159
+ current = default ! ;
283
160
return false ;
284
161
}
285
162
@@ -324,7 +201,7 @@ public bool TryGetNext(out T current)
324
201
return true ;
325
202
}
326
203
327
- Unsafe . SkipInit ( out current ) ;
204
+ current = default ! ;
328
205
return false ;
329
206
}
330
207
@@ -369,7 +246,7 @@ public bool TryGetNext(out T current)
369
246
return true ;
370
247
}
371
248
372
- Unsafe . SkipInit ( out current ) ;
249
+ current = default ! ;
373
250
return false ;
374
251
}
375
252
@@ -415,7 +292,7 @@ public bool TryGetNext(out KVPair<TKey, TValue> current)
415
292
return true ;
416
293
}
417
294
418
- Unsafe . SkipInit ( out current ) ;
295
+ current = default ! ;
419
296
return false ;
420
297
}
421
298
@@ -457,7 +334,7 @@ public bool TryGetNext(out Unicode.Rune current)
457
334
return true ;
458
335
}
459
336
460
- Unsafe . SkipInit ( out current ) ;
337
+ current = default ! ;
461
338
return false ;
462
339
}
463
340
@@ -500,7 +377,7 @@ public bool TryGetNext(out T current)
500
377
return true ;
501
378
}
502
379
503
- Unsafe . SkipInit ( out current ) ;
380
+ current = default ! ;
504
381
return false ;
505
382
}
506
383
@@ -543,7 +420,7 @@ public bool TryGetNext(out T current)
543
420
return true ;
544
421
}
545
422
546
- Unsafe . SkipInit ( out current ) ;
423
+ current = default ! ;
547
424
return false ;
548
425
}
549
426
@@ -586,7 +463,7 @@ public bool TryGetNext(out T current)
586
463
return true ;
587
464
}
588
465
589
- Unsafe . SkipInit ( out current ) ;
466
+ current = default ! ;
590
467
return false ;
591
468
}
592
469
@@ -629,7 +506,7 @@ public bool TryGetNext(out T current)
629
506
return true ;
630
507
}
631
508
632
- Unsafe . SkipInit ( out current ) ;
509
+ current = default ! ;
633
510
return false ;
634
511
}
635
512
@@ -672,7 +549,7 @@ public bool TryGetNext(out T current)
672
549
return true ;
673
550
}
674
551
675
- Unsafe . SkipInit ( out current ) ;
552
+ current = default ! ;
676
553
return false ;
677
554
}
678
555
@@ -714,7 +591,7 @@ public bool TryGetNext(out Unicode.Rune current)
714
591
return true ;
715
592
}
716
593
717
- Unsafe . SkipInit ( out current ) ;
594
+ current = default ! ;
718
595
return false ;
719
596
}
720
597
@@ -756,7 +633,7 @@ public bool TryGetNext(out Unicode.Rune current)
756
633
return true ;
757
634
}
758
635
759
- Unsafe . SkipInit ( out current ) ;
636
+ current = default ! ;
760
637
return false ;
761
638
}
762
639
@@ -798,7 +675,7 @@ public bool TryGetNext(out Unicode.Rune current)
798
675
return true ;
799
676
}
800
677
801
- Unsafe . SkipInit ( out current ) ;
678
+ current = default ! ;
802
679
return false ;
803
680
}
804
681
@@ -840,7 +717,7 @@ public bool TryGetNext(out Unicode.Rune current)
840
717
return true ;
841
718
}
842
719
843
- Unsafe . SkipInit ( out current ) ;
720
+ current = default ! ;
844
721
return false ;
845
722
}
846
723
@@ -882,7 +759,7 @@ public bool TryGetNext(out Unicode.Rune current)
882
759
return true ;
883
760
}
884
761
885
- Unsafe . SkipInit ( out current ) ;
762
+ current = default ! ;
886
763
return false ;
887
764
}
888
765
@@ -901,4 +778,4 @@ public unsafe bool TryGetSpan(out ReadOnlySpan<Unicode.Rune> span)
901
778
#endif
902
779
}
903
780
904
- #pragma warning restore CS9074
781
+ #pragma warning restore CS9074
0 commit comments