File tree Expand file tree Collapse file tree
CommonExtendedObjectsTests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515using System . Diagnostics ;
1616using System . Linq ;
1717using ExtendedSystemObjects ;
18+ using ExtendedSystemObjects . Helper ;
1819using ExtendedSystemObjects . Interfaces ;
1920using Mathematics ;
2021using Microsoft . VisualStudio . TestTools . UnitTesting ;
Original file line number Diff line number Diff line change 1212using System . IO ;
1313using System . Threading ;
1414using ExtendedSystemObjects ;
15+ using ExtendedSystemObjects . Helper ;
1516using ImageCompare ;
1617using NUnit . Framework ;
1718using Solaris ;
Original file line number Diff line number Diff line change 1313using System . Collections . Generic ;
1414using System . Linq ;
1515using System . Runtime . CompilerServices ;
16+ using ExtendedSystemObjects . Helper ;
1617using ExtendedSystemObjects . Interfaces ;
1718
1819namespace ExtendedSystemObjects
Original file line number Diff line number Diff line change 1515using System . Linq ;
1616using System . Runtime . CompilerServices ;
1717using System . Security . Cryptography ;
18+ using ExtendedSystemObjects . Helper ;
1819using ExtendedSystemObjects . Interfaces ;
1920
2021namespace ExtendedSystemObjects
Original file line number Diff line number Diff line change 11/*
22 * COPYRIGHT: See COPYING in the top level directory
3- * PROJECT: ExtendedSystemObjects
4- * FILE: ExtendedSystemObjects/EnumerableCompare.cs
3+ * PROJECT: ExtendedSystemObjects.Helper
4+ * FILE: ExtendedSystemObjects.Helper /EnumerableCompare.cs
55 * PURPOSE: Compare operator, for now mostly Enumerable
66 * PROGRAMER: Peter Geinitz (Wayfarer)
77 */
88
9- namespace ExtendedSystemObjects
9+ namespace ExtendedSystemObjects . Helper
1010{
1111 /// <summary>
1212 /// Compare conditions for lists
Original file line number Diff line number Diff line change 1+ /*
2+ * COPYRIGHT: See COPYING in the top level directory
3+ * PROJECT: ExtendedSystemObjects.Helper
4+ * FILE: ExtendedSystemObjects.Helper/Enumerator.cs
5+ * PURPOSE: Since I use an older .etn Version I need to use this helper
6+ * PROGRAMER: Peter Geinitz (Wayfarer)
7+ */
8+
9+ using System . Collections ;
10+ using System . Collections . Generic ;
11+ using System . Runtime . CompilerServices ;
12+
13+ namespace ExtendedSystemObjects . Helper
14+ {
15+ internal unsafe struct Enumerator < T > : IEnumerator < T > where T : unmanaged
16+ {
17+ private readonly T * _data ;
18+ private readonly int _length ;
19+ private int _index ;
20+
21+ public Enumerator ( T * data , int length )
22+ {
23+ _data = data ;
24+ _length = length ;
25+ _index = - 1 ;
26+ }
27+
28+ public T Current
29+ {
30+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
31+ get => _data [ _index ] ;
32+ }
33+
34+ object IEnumerator . Current => Current ;
35+
36+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
37+ public bool MoveNext ( ) => ++ _index < _length ;
38+
39+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
40+ public void Reset ( ) => _index = - 1 ;
41+
42+ public void Dispose ( ) { /* no resources to clean */ }
43+ }
44+ }
Original file line number Diff line number Diff line change 11/*
22 * COPYRIGHT: See COPYING in the top level directory
3- * PROJECT: ExtendedSystemObjects
4- * FILE: ExtendedSystemObjects/ValueNotFoundException.cs
3+ * PROJECT: ExtendedSystemObjects.Helper
4+ * FILE: ExtendedSystemObjects.Helper /ValueNotFoundException.cs
55 * PURPOSE: New Exceptions for ExtendedSystemObjects
66 * PROGRAMER: Peter Geinitz (Wayfarer)
77 */
88
99using System ;
1010using System . Runtime . Serialization ;
1111
12- namespace ExtendedSystemObjects
12+ namespace ExtendedSystemObjects . Helper
1313{
1414 /// <inheritdoc />
1515 /// <summary>
Original file line number Diff line number Diff line change 11/*
22 * COPYRIGHT: See COPYING in the top level directory
3- * PROJECT: ExtendedSystemObjects
4- * FILE: ExtendedSystemObjects/VaultMemoryThresholdExceededEventArgs.cs
3+ * PROJECT: ExtendedSystemObjects.Helper
4+ * FILE: ExtendedSystemObjects.Helper /VaultMemoryThresholdExceededEventArgs.cs
55 * PURPOSE: Event when Memory exceeds a certain threshold.
66 * PROGRAMER: Peter Geinitz (Wayfarer)
77 */
1111
1212using System ;
1313
14- namespace ExtendedSystemObjects
14+ namespace ExtendedSystemObjects . Helper
1515{
1616 /// <inheritdoc />
1717 /// <summary>
Original file line number Diff line number Diff line change 99// ReSharper disable MemberCanBeInternal
1010
1111using System ;
12+ using System . Collections ;
13+ using System . Collections . Generic ;
1214using System . Runtime . CompilerServices ;
1315using System . Runtime . InteropServices ;
1416using ExtendedSystemObjects . Interfaces ;
@@ -21,7 +23,7 @@ namespace ExtendedSystemObjects
2123 /// backed by unmanaged memory. Designed for performance-critical
2224 /// scenarios where garbage collection overhead must be avoided.
2325 /// </summary>
24- public sealed unsafe class IntArray : IUnmanagedArray < int >
26+ public sealed unsafe class IntArray : IUnmanagedArray < int > , IEnumerable < int >
2527 {
2628 /// <summary>
2729 /// The buffer
@@ -137,6 +139,27 @@ public void Resize(int newSize)
137139 }
138140 }
139141
142+ /// <summary>
143+ /// Returns an enumerator that iterates through the collection.
144+ /// </summary>
145+ /// <returns>
146+ /// An enumerator that can be used to iterate through the collection.
147+ /// </returns>
148+ public IEnumerator < int > GetEnumerator ( )
149+ {
150+ return new Enumerator < int > ( _ptr , Length ) ;
151+ }
152+
153+ /// <summary>
154+ /// Returns an enumerator that iterates through a collection.
155+ /// </summary>
156+ /// <returns>
157+ /// An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
158+ /// </returns>
159+ IEnumerator IEnumerable . GetEnumerator ( )
160+ {
161+ return GetEnumerator ( ) ;
162+ }
140163
141164 /// <inheritdoc />
142165 /// <summary>
Original file line number Diff line number Diff line change 1212// ReSharper disable MemberCanBeInternal
1313
1414using System ;
15+ using System . Collections ;
16+ using System . Collections . Generic ;
1517using System . Runtime . InteropServices ;
1618using ExtendedSystemObjects . Interfaces ;
1719
@@ -24,7 +26,7 @@ namespace ExtendedSystemObjects
2426 /// Designed for scenarios where manual memory management is needed.
2527 /// </summary>
2628 /// <seealso cref="T:System.IDisposable" />
27- public sealed unsafe class IntList : IUnmanagedArray < int >
29+ public sealed unsafe class IntList : IUnmanagedArray < int > , IEnumerable < int >
2830 {
2931 /// <summary>
3032 /// The buffer
@@ -114,6 +116,28 @@ public void RemoveAt(int index)
114116 Length -- ;
115117 }
116118
119+ /// <summary>
120+ /// Returns an enumerator that iterates through the collection.
121+ /// </summary>
122+ /// <returns>
123+ /// An enumerator that can be used to iterate through the collection.
124+ /// </returns>
125+ public IEnumerator < int > GetEnumerator ( )
126+ {
127+ return new Enumerator < int > ( _ptr , Length ) ;
128+ }
129+
130+ /// <summary>
131+ /// Returns an enumerator that iterates through a collection.
132+ /// </summary>
133+ /// <returns>
134+ /// An <see cref="T:System.Collections.IEnumerator" /> object that can be used to iterate through the collection.
135+ /// </returns>
136+ IEnumerator IEnumerable . GetEnumerator ( )
137+ {
138+ return GetEnumerator ( ) ;
139+ }
140+
117141 /// <summary>
118142 /// Resizes the specified new size.
119143 /// </summary>
You can’t perform that action at this time.
0 commit comments