From a26f5bd69acac920c7dfaab33df0daf4694a3845 Mon Sep 17 00:00:00 2001 From: Basewq Date: Mon, 9 Mar 2020 12:48:03 +1300 Subject: [PATCH 1/2] Fix all enumerators Reset methods --- BulletSharp/Collision/DbvtArray.cs | 2 +- BulletSharp/Collision/DbvtNodePtrArray.cs | 2 +- BulletSharp/Common/GenericListEnumerator.cs | 2 +- BulletSharp/LinearMath/AlignedBroadphasePairArray.cs | 2 +- BulletSharp/LinearMath/AlignedCollisionObjectArray.cs | 2 +- BulletSharp/LinearMath/AlignedIndexedMeshArray.cs | 2 +- BulletSharp/LinearMath/AlignedManifoldArray.cs | 2 +- BulletSharp/LinearMath/Collections.cs | 4 ++-- BulletSharp/Math/Vector3Array.cs | 2 +- BulletSharp/SoftBody/AlignedAnchorArray.cs | 2 +- BulletSharp/SoftBody/AlignedClusterArray.cs | 2 +- BulletSharp/SoftBody/AlignedFaceArray.cs | 2 +- BulletSharp/SoftBody/AlignedJointArray.cs | 2 +- BulletSharp/SoftBody/AlignedLinkArray.cs | 2 +- BulletSharp/SoftBody/AlignedMaterialArray.cs | 2 +- BulletSharp/SoftBody/AlignedNodeArray.cs | 2 +- BulletSharp/SoftBody/AlignedSoftBodyArray.cs | 2 +- BulletSharp/SoftBody/AlignedTetraArray.cs | 2 +- BulletSharp/SoftBody/AlignedTetraScratchArray.cs | 2 +- BulletSharp/SoftBody/Collections.cs | 2 +- 20 files changed, 21 insertions(+), 21 deletions(-) diff --git a/BulletSharp/Collision/DbvtArray.cs b/BulletSharp/Collision/DbvtArray.cs index 309d9d97e..9a7b1932e 100644 --- a/BulletSharp/Collision/DbvtArray.cs +++ b/BulletSharp/Collision/DbvtArray.cs @@ -30,7 +30,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } public Dbvt Current => _array[_i]; diff --git a/BulletSharp/Collision/DbvtNodePtrArray.cs b/BulletSharp/Collision/DbvtNodePtrArray.cs index 80d2a3a08..e5d67f664 100644 --- a/BulletSharp/Collision/DbvtNodePtrArray.cs +++ b/BulletSharp/Collision/DbvtNodePtrArray.cs @@ -30,7 +30,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } public DbvtNode Current => _array[_i]; diff --git a/BulletSharp/Common/GenericListEnumerator.cs b/BulletSharp/Common/GenericListEnumerator.cs index f18ba8daf..f010bcf73 100644 --- a/BulletSharp/Common/GenericListEnumerator.cs +++ b/BulletSharp/Common/GenericListEnumerator.cs @@ -28,7 +28,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } public void Dispose() diff --git a/BulletSharp/LinearMath/AlignedBroadphasePairArray.cs b/BulletSharp/LinearMath/AlignedBroadphasePairArray.cs index 5ee4350b5..c948a1220 100644 --- a/BulletSharp/LinearMath/AlignedBroadphasePairArray.cs +++ b/BulletSharp/LinearMath/AlignedBroadphasePairArray.cs @@ -57,7 +57,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/LinearMath/AlignedCollisionObjectArray.cs b/BulletSharp/LinearMath/AlignedCollisionObjectArray.cs index a6540a011..884721145 100644 --- a/BulletSharp/LinearMath/AlignedCollisionObjectArray.cs +++ b/BulletSharp/LinearMath/AlignedCollisionObjectArray.cs @@ -57,7 +57,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/LinearMath/AlignedIndexedMeshArray.cs b/BulletSharp/LinearMath/AlignedIndexedMeshArray.cs index c37132d75..e0b793b3d 100644 --- a/BulletSharp/LinearMath/AlignedIndexedMeshArray.cs +++ b/BulletSharp/LinearMath/AlignedIndexedMeshArray.cs @@ -58,7 +58,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/LinearMath/AlignedManifoldArray.cs b/BulletSharp/LinearMath/AlignedManifoldArray.cs index 9a2d73e7f..75ad677fb 100644 --- a/BulletSharp/LinearMath/AlignedManifoldArray.cs +++ b/BulletSharp/LinearMath/AlignedManifoldArray.cs @@ -58,7 +58,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/LinearMath/Collections.cs b/BulletSharp/LinearMath/Collections.cs index 0a41809f9..364a372cc 100644 --- a/BulletSharp/LinearMath/Collections.cs +++ b/BulletSharp/LinearMath/Collections.cs @@ -54,7 +54,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } public CompoundShapeChild Current => _array[_i]; @@ -87,7 +87,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } public uint Current => _array[_i]; diff --git a/BulletSharp/Math/Vector3Array.cs b/BulletSharp/Math/Vector3Array.cs index f23db25e3..564370a3a 100644 --- a/BulletSharp/Math/Vector3Array.cs +++ b/BulletSharp/Math/Vector3Array.cs @@ -51,7 +51,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } public Vector3 Current => _array[_i]; diff --git a/BulletSharp/SoftBody/AlignedAnchorArray.cs b/BulletSharp/SoftBody/AlignedAnchorArray.cs index 123e230da..14b64fb54 100644 --- a/BulletSharp/SoftBody/AlignedAnchorArray.cs +++ b/BulletSharp/SoftBody/AlignedAnchorArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/AlignedClusterArray.cs b/BulletSharp/SoftBody/AlignedClusterArray.cs index 7fbb72a58..79430ff4e 100644 --- a/BulletSharp/SoftBody/AlignedClusterArray.cs +++ b/BulletSharp/SoftBody/AlignedClusterArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/AlignedFaceArray.cs b/BulletSharp/SoftBody/AlignedFaceArray.cs index 1c2f7d0c0..b9b0d37e5 100644 --- a/BulletSharp/SoftBody/AlignedFaceArray.cs +++ b/BulletSharp/SoftBody/AlignedFaceArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/AlignedJointArray.cs b/BulletSharp/SoftBody/AlignedJointArray.cs index 6b2a04ddc..a6551ab50 100644 --- a/BulletSharp/SoftBody/AlignedJointArray.cs +++ b/BulletSharp/SoftBody/AlignedJointArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/AlignedLinkArray.cs b/BulletSharp/SoftBody/AlignedLinkArray.cs index 5d3589858..326a62a5d 100644 --- a/BulletSharp/SoftBody/AlignedLinkArray.cs +++ b/BulletSharp/SoftBody/AlignedLinkArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/AlignedMaterialArray.cs b/BulletSharp/SoftBody/AlignedMaterialArray.cs index 189888478..a8f1a83ff 100644 --- a/BulletSharp/SoftBody/AlignedMaterialArray.cs +++ b/BulletSharp/SoftBody/AlignedMaterialArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/AlignedNodeArray.cs b/BulletSharp/SoftBody/AlignedNodeArray.cs index af6e16c2d..5516ac7f4 100644 --- a/BulletSharp/SoftBody/AlignedNodeArray.cs +++ b/BulletSharp/SoftBody/AlignedNodeArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/AlignedSoftBodyArray.cs b/BulletSharp/SoftBody/AlignedSoftBodyArray.cs index aa7248a65..f2071f062 100644 --- a/BulletSharp/SoftBody/AlignedSoftBodyArray.cs +++ b/BulletSharp/SoftBody/AlignedSoftBodyArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/AlignedTetraArray.cs b/BulletSharp/SoftBody/AlignedTetraArray.cs index 045aa6eaa..a63b60ad7 100644 --- a/BulletSharp/SoftBody/AlignedTetraArray.cs +++ b/BulletSharp/SoftBody/AlignedTetraArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/AlignedTetraScratchArray.cs b/BulletSharp/SoftBody/AlignedTetraScratchArray.cs index f56d19fd7..27d5ea0c5 100644 --- a/BulletSharp/SoftBody/AlignedTetraScratchArray.cs +++ b/BulletSharp/SoftBody/AlignedTetraScratchArray.cs @@ -59,7 +59,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } } diff --git a/BulletSharp/SoftBody/Collections.cs b/BulletSharp/SoftBody/Collections.cs index bd1dfba11..f60df39bc 100644 --- a/BulletSharp/SoftBody/Collections.cs +++ b/BulletSharp/SoftBody/Collections.cs @@ -29,7 +29,7 @@ public bool MoveNext() public void Reset() { - _i = 0; + _i = -1; } public Node Current => _array[_i]; From a188bdda7e5f838833d3c52041681f8cfe723d57 Mon Sep 17 00:00:00 2001 From: Basewq Date: Mon, 9 Mar 2020 13:46:21 +1300 Subject: [PATCH 2/2] Change enumerators to structs to prevent boxing/object allocation when concrete classes are used with foreach statements --- BulletSharp/Collision/DbvtArray.cs | 9 +++++++-- BulletSharp/Collision/DbvtNodePtrArray.cs | 9 +++++++-- BulletSharp/Common/GenericListEnumerator.cs | 2 +- .../LinearMath/AlignedBroadphasePairArray.cs | 12 +++++++++--- .../LinearMath/AlignedCollisionObjectArray.cs | 12 +++++++++--- .../LinearMath/AlignedIndexedMeshArray.cs | 9 +++++++-- BulletSharp/LinearMath/AlignedManifoldArray.cs | 9 +++++++-- BulletSharp/LinearMath/Collections.cs | 18 ++++++++++++++---- BulletSharp/Math/Vector3Array.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedAnchorArray.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedClusterArray.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedFaceArray.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedJointArray.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedLinkArray.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedMaterialArray.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedNodeArray.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedNoteArray.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedSoftBodyArray.cs | 9 +++++++-- BulletSharp/SoftBody/AlignedTetraArray.cs | 9 +++++++-- .../SoftBody/AlignedTetraScratchArray.cs | 9 +++++++-- BulletSharp/SoftBody/BodyArray.cs | 7 ++++++- BulletSharp/SoftBody/Collections.cs | 9 +++++++-- 22 files changed, 158 insertions(+), 46 deletions(-) diff --git a/BulletSharp/Collision/DbvtArray.cs b/BulletSharp/Collision/DbvtArray.cs index 9a7b1932e..9df5eace2 100644 --- a/BulletSharp/Collision/DbvtArray.cs +++ b/BulletSharp/Collision/DbvtArray.cs @@ -5,7 +5,7 @@ namespace BulletSharp { - public class DbvtArrayEnumerator : IEnumerator + public struct DbvtArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -92,7 +92,12 @@ public void CopyTo(Dbvt[] array, int arrayIndex) } } - public IEnumerator GetEnumerator() + public DbvtArrayEnumerator GetEnumerator() + { + return new DbvtArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new DbvtArrayEnumerator(this); } diff --git a/BulletSharp/Collision/DbvtNodePtrArray.cs b/BulletSharp/Collision/DbvtNodePtrArray.cs index e5d67f664..bb433bcb7 100644 --- a/BulletSharp/Collision/DbvtNodePtrArray.cs +++ b/BulletSharp/Collision/DbvtNodePtrArray.cs @@ -5,7 +5,7 @@ namespace BulletSharp { - public class DbvtNodePtrArrayEnumerator : IEnumerator + public struct DbvtNodePtrArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -92,7 +92,12 @@ public void CopyTo(DbvtNode[] array, int arrayIndex) } } - public IEnumerator GetEnumerator() + public DbvtNodePtrArrayEnumerator GetEnumerator() + { + return new DbvtNodePtrArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new DbvtNodePtrArrayEnumerator(this); } diff --git a/BulletSharp/Common/GenericListEnumerator.cs b/BulletSharp/Common/GenericListEnumerator.cs index f010bcf73..bc70675d1 100644 --- a/BulletSharp/Common/GenericListEnumerator.cs +++ b/BulletSharp/Common/GenericListEnumerator.cs @@ -3,7 +3,7 @@ namespace BulletSharp { - public sealed class GenericListEnumerator : IEnumerator + public struct GenericListEnumerator : IEnumerator { private int _i; private readonly int _count; diff --git a/BulletSharp/LinearMath/AlignedBroadphasePairArray.cs b/BulletSharp/LinearMath/AlignedBroadphasePairArray.cs index c948a1220..e99710581 100644 --- a/BulletSharp/LinearMath/AlignedBroadphasePairArray.cs +++ b/BulletSharp/LinearMath/AlignedBroadphasePairArray.cs @@ -29,9 +29,9 @@ public BroadphasePair[] Items } } - public class AlignedBroadphasePairArrayEnumerator : IEnumerator + public struct AlignedBroadphasePairArrayEnumerator : IEnumerator { - private int _i = -1; + private int _i; private readonly int _count; private readonly AlignedBroadphasePairArray _array; @@ -39,6 +39,7 @@ public AlignedBroadphasePairArrayEnumerator(AlignedBroadphasePairArray array) { _array = array; _count = array.Count; + _i = -1; } public BroadphasePair Current => _array[_i]; @@ -144,7 +145,12 @@ public bool Remove(BroadphasePair item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedBroadphasePairArrayEnumerator GetEnumerator() + { + return new AlignedBroadphasePairArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedBroadphasePairArrayEnumerator(this); } diff --git a/BulletSharp/LinearMath/AlignedCollisionObjectArray.cs b/BulletSharp/LinearMath/AlignedCollisionObjectArray.cs index 884721145..358bea29c 100644 --- a/BulletSharp/LinearMath/AlignedCollisionObjectArray.cs +++ b/BulletSharp/LinearMath/AlignedCollisionObjectArray.cs @@ -29,9 +29,9 @@ public CollisionObject[] Items } } - public class AlignedCollisionObjectArrayEnumerator : IEnumerator + public struct AlignedCollisionObjectArrayEnumerator : IEnumerator { - private int _i = -1; + private int _i; private readonly int _count; private readonly IList _array; @@ -39,6 +39,7 @@ public AlignedCollisionObjectArrayEnumerator(IList array) { _array = array; _count = array.Count; + _i = -1; } public CollisionObject Current => _array[_i]; @@ -256,7 +257,12 @@ private void SetBodyBroadphaseHandle(CollisionObject item, BroadphaseInterface b } } - public IEnumerator GetEnumerator() + public AlignedCollisionObjectArrayEnumerator GetEnumerator() + { + return new AlignedCollisionObjectArrayEnumerator(_backingList ?? this as IList); + } + + IEnumerator IEnumerable.GetEnumerator() { if (_backingList != null) { diff --git a/BulletSharp/LinearMath/AlignedIndexedMeshArray.cs b/BulletSharp/LinearMath/AlignedIndexedMeshArray.cs index e0b793b3d..41369f193 100644 --- a/BulletSharp/LinearMath/AlignedIndexedMeshArray.cs +++ b/BulletSharp/LinearMath/AlignedIndexedMeshArray.cs @@ -29,7 +29,7 @@ public IndexedMesh[] Items } } - public class AlignedIndexedMeshArrayEnumerator : IEnumerator + public struct AlignedIndexedMeshArrayEnumerator : IEnumerator { private int _i; private readonly int _count; @@ -154,7 +154,12 @@ public bool Remove(IndexedMesh item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedIndexedMeshArrayEnumerator GetEnumerator() + { + return new AlignedIndexedMeshArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return _backingList.GetEnumerator(); } diff --git a/BulletSharp/LinearMath/AlignedManifoldArray.cs b/BulletSharp/LinearMath/AlignedManifoldArray.cs index 75ad677fb..32c9b6898 100644 --- a/BulletSharp/LinearMath/AlignedManifoldArray.cs +++ b/BulletSharp/LinearMath/AlignedManifoldArray.cs @@ -29,7 +29,7 @@ public PersistentManifold[] Items } } - public class AlignedManifoldArrayEnumerator : IEnumerator + public struct AlignedManifoldArrayEnumerator : IEnumerator { private int _i; private readonly int _count; @@ -144,7 +144,12 @@ public bool Remove(PersistentManifold item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedManifoldArrayEnumerator GetEnumerator() + { + return new AlignedManifoldArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedManifoldArrayEnumerator(this); } diff --git a/BulletSharp/LinearMath/Collections.cs b/BulletSharp/LinearMath/Collections.cs index 364a372cc..649a2b3dc 100644 --- a/BulletSharp/LinearMath/Collections.cs +++ b/BulletSharp/LinearMath/Collections.cs @@ -29,7 +29,7 @@ public System.Collections.ArrayList Items } }; - public class CompoundShapeChildArrayEnumerator : IEnumerator + public struct CompoundShapeChildArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -62,7 +62,7 @@ public void Reset() object System.Collections.IEnumerator.Current => _array[_i]; } - public class UIntArrayEnumerator : IEnumerator + public struct UIntArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -147,7 +147,12 @@ public void CopyTo(CompoundShapeChild[] array, int arrayIndex) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public CompoundShapeChildArrayEnumerator GetEnumerator() + { + return new CompoundShapeChildArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new CompoundShapeChildArrayEnumerator(this); } @@ -228,7 +233,12 @@ public void CopyTo(uint[] array, int arrayIndex) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public UIntArrayEnumerator GetEnumerator() + { + return new UIntArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new UIntArrayEnumerator(this); } diff --git a/BulletSharp/Math/Vector3Array.cs b/BulletSharp/Math/Vector3Array.cs index 564370a3a..aeb772a17 100644 --- a/BulletSharp/Math/Vector3Array.cs +++ b/BulletSharp/Math/Vector3Array.cs @@ -26,7 +26,7 @@ public Vector3[] Items } }; - public class Vector3ArrayEnumerator : IEnumerator + public struct Vector3ArrayEnumerator : IEnumerator { private int _i; private readonly int _count; @@ -127,7 +127,12 @@ public void CopyTo(Vector3[] array, int arrayIndex) } } - public IEnumerator GetEnumerator() + public Vector3ArrayEnumerator GetEnumerator() + { + return new Vector3ArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new Vector3ArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedAnchorArray.cs b/BulletSharp/SoftBody/AlignedAnchorArray.cs index 14b64fb54..a4f351ab9 100644 --- a/BulletSharp/SoftBody/AlignedAnchorArray.cs +++ b/BulletSharp/SoftBody/AlignedAnchorArray.cs @@ -30,7 +30,7 @@ public Anchor[] Items } } - public class AlignedAnchorArrayEnumerator : IEnumerator + public struct AlignedAnchorArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -131,7 +131,12 @@ public bool Remove(Anchor item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedAnchorArrayEnumerator GetEnumerator() + { + return new AlignedAnchorArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedAnchorArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedClusterArray.cs b/BulletSharp/SoftBody/AlignedClusterArray.cs index 79430ff4e..b8bfa35fd 100644 --- a/BulletSharp/SoftBody/AlignedClusterArray.cs +++ b/BulletSharp/SoftBody/AlignedClusterArray.cs @@ -30,7 +30,7 @@ public Cluster[] Items } } - public class AlignedClusterArrayEnumerator : IEnumerator + public struct AlignedClusterArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -131,7 +131,12 @@ public bool Remove(Cluster item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedClusterArrayEnumerator GetEnumerator() + { + return new AlignedClusterArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedClusterArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedFaceArray.cs b/BulletSharp/SoftBody/AlignedFaceArray.cs index b9b0d37e5..e6f3018a5 100644 --- a/BulletSharp/SoftBody/AlignedFaceArray.cs +++ b/BulletSharp/SoftBody/AlignedFaceArray.cs @@ -30,7 +30,7 @@ public Face[] Items } } - public class AlignedFaceArrayEnumerator : IEnumerator + public struct AlignedFaceArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -131,7 +131,12 @@ public bool Remove(Face item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedFaceArrayEnumerator GetEnumerator() + { + return new AlignedFaceArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedFaceArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedJointArray.cs b/BulletSharp/SoftBody/AlignedJointArray.cs index a6551ab50..a7e02f0de 100644 --- a/BulletSharp/SoftBody/AlignedJointArray.cs +++ b/BulletSharp/SoftBody/AlignedJointArray.cs @@ -30,7 +30,7 @@ public Joint[] Items } } - public class AlignedJointArrayEnumerator : IEnumerator + public struct AlignedJointArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -131,7 +131,12 @@ public bool Remove(Joint item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedJointArrayEnumerator GetEnumerator() + { + return new AlignedJointArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedJointArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedLinkArray.cs b/BulletSharp/SoftBody/AlignedLinkArray.cs index 326a62a5d..5f7b09afe 100644 --- a/BulletSharp/SoftBody/AlignedLinkArray.cs +++ b/BulletSharp/SoftBody/AlignedLinkArray.cs @@ -30,7 +30,7 @@ public Link[] Items } } - public class AlignedLinkArrayEnumerator : IEnumerator + public struct AlignedLinkArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -148,7 +148,12 @@ public bool Remove(Link item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedLinkArrayEnumerator GetEnumerator() + { + return new AlignedLinkArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedLinkArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedMaterialArray.cs b/BulletSharp/SoftBody/AlignedMaterialArray.cs index a8f1a83ff..ebafacb3e 100644 --- a/BulletSharp/SoftBody/AlignedMaterialArray.cs +++ b/BulletSharp/SoftBody/AlignedMaterialArray.cs @@ -30,7 +30,7 @@ public Material[] Items } } - public class AlignedMaterialArrayEnumerator : IEnumerator + public struct AlignedMaterialArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -131,7 +131,12 @@ public bool Remove(Material item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedMaterialArrayEnumerator GetEnumerator() + { + return new AlignedMaterialArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedMaterialArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedNodeArray.cs b/BulletSharp/SoftBody/AlignedNodeArray.cs index 5516ac7f4..ff4a6d72a 100644 --- a/BulletSharp/SoftBody/AlignedNodeArray.cs +++ b/BulletSharp/SoftBody/AlignedNodeArray.cs @@ -30,7 +30,7 @@ public Node[] Items } } - public class AlignedNodeArrayEnumerator : IEnumerator + public struct AlignedNodeArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -131,7 +131,12 @@ public bool Remove(Node item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedNodeArrayEnumerator GetEnumerator() + { + return new AlignedNodeArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedNodeArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedNoteArray.cs b/BulletSharp/SoftBody/AlignedNoteArray.cs index 4d651afde..1de32c229 100644 --- a/BulletSharp/SoftBody/AlignedNoteArray.cs +++ b/BulletSharp/SoftBody/AlignedNoteArray.cs @@ -30,7 +30,7 @@ public Note[] Items } } - public class AlignedNoteArrayEnumerator : IEnumerator + public struct AlignedNoteArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -131,7 +131,12 @@ public bool Remove(Note item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedNoteArrayEnumerator GetEnumerator() + { + return new AlignedNoteArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedNoteArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedSoftBodyArray.cs b/BulletSharp/SoftBody/AlignedSoftBodyArray.cs index f2071f062..6f07b61de 100644 --- a/BulletSharp/SoftBody/AlignedSoftBodyArray.cs +++ b/BulletSharp/SoftBody/AlignedSoftBodyArray.cs @@ -30,7 +30,7 @@ public SoftBody[] Items } } - public class AlignedSoftBodyArrayEnumerator : IEnumerator + public struct AlignedSoftBodyArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -131,7 +131,12 @@ public bool Remove(SoftBody item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedSoftBodyArrayEnumerator GetEnumerator() + { + return new AlignedSoftBodyArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedSoftBodyArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedTetraArray.cs b/BulletSharp/SoftBody/AlignedTetraArray.cs index a63b60ad7..48274c1c7 100644 --- a/BulletSharp/SoftBody/AlignedTetraArray.cs +++ b/BulletSharp/SoftBody/AlignedTetraArray.cs @@ -30,7 +30,7 @@ public Tetra[] Items } } - public class AlignedTetraArrayEnumerator : IEnumerator + public struct AlignedTetraArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -131,7 +131,12 @@ public bool Remove(Tetra item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedTetraArrayEnumerator GetEnumerator() + { + return new AlignedTetraArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedTetraArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/AlignedTetraScratchArray.cs b/BulletSharp/SoftBody/AlignedTetraScratchArray.cs index 27d5ea0c5..972ada9eb 100644 --- a/BulletSharp/SoftBody/AlignedTetraScratchArray.cs +++ b/BulletSharp/SoftBody/AlignedTetraScratchArray.cs @@ -30,7 +30,7 @@ public TetraScratch[] Items } } - public class AlignedTetraScratchArrayEnumerator : IEnumerator + public struct AlignedTetraScratchArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -136,7 +136,12 @@ public bool Remove(TetraScratch item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public AlignedTetraScratchArrayEnumerator GetEnumerator() + { + return new AlignedTetraScratchArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new AlignedTetraScratchArrayEnumerator(this); } diff --git a/BulletSharp/SoftBody/BodyArray.cs b/BulletSharp/SoftBody/BodyArray.cs index d1fc0b6b3..fe8adb3b3 100644 --- a/BulletSharp/SoftBody/BodyArray.cs +++ b/BulletSharp/SoftBody/BodyArray.cs @@ -47,7 +47,12 @@ public int IndexOf(Body item) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public GenericListEnumerator GetEnumerator() + { + return new GenericListEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new GenericListEnumerator(this); } diff --git a/BulletSharp/SoftBody/Collections.cs b/BulletSharp/SoftBody/Collections.cs index f60df39bc..57caffc39 100644 --- a/BulletSharp/SoftBody/Collections.cs +++ b/BulletSharp/SoftBody/Collections.cs @@ -4,7 +4,7 @@ namespace BulletSharp.SoftBody { - public class NodePtrArrayEnumerator : IEnumerator + public struct NodePtrArrayEnumerator : IEnumerator { private int _i; private int _count; @@ -75,7 +75,12 @@ public void CopyTo(Node[] array, int arrayIndex) throw new NotImplementedException(); } - public IEnumerator GetEnumerator() + public NodePtrArrayEnumerator GetEnumerator() + { + return new NodePtrArrayEnumerator(this); + } + + IEnumerator IEnumerable.GetEnumerator() { return new NodePtrArrayEnumerator(this); }