summaryrefslogtreecommitdiff
path: root/MorgSimulator/Framework/EntityIterator.cs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2025-11-20 19:17:14 -0800
committerFuwn <[email protected]>2025-11-20 19:17:14 -0800
commit9858b069ea4264840d98094e2e36ad2517f2215f (patch)
tree367ac8bcab6107ef8dfa4be524f834a5336d9bc3 /MorgSimulator/Framework/EntityIterator.cs
parentfeat: Add Assignment 2 diagrams (diff)
downloadcst276-9858b069ea4264840d98094e2e36ad2517f2215f.tar.xz
cst276-9858b069ea4264840d98094e2e36ad2517f2215f.zip
feat: Implement Assignment 3 functionality
Diffstat (limited to 'MorgSimulator/Framework/EntityIterator.cs')
-rw-r--r--MorgSimulator/Framework/EntityIterator.cs35
1 files changed, 35 insertions, 0 deletions
diff --git a/MorgSimulator/Framework/EntityIterator.cs b/MorgSimulator/Framework/EntityIterator.cs
new file mode 100644
index 0000000..84976c7
--- /dev/null
+++ b/MorgSimulator/Framework/EntityIterator.cs
@@ -0,0 +1,35 @@
+#nullable enable
+using System.Collections.Generic;
+
+namespace MorgSimulator.Framework
+{
+ public class EntityIterator<T> : IEntityIterator<T> where T : Entity
+ {
+ private readonly List<T> _entities;
+ private int _currentIndex = 0;
+
+ public EntityIterator(List<T> entities)
+ {
+ _entities = entities;
+ }
+
+ public bool HasNext()
+ {
+ return _currentIndex < _entities.Count;
+ }
+
+ public T? Next()
+ {
+ if (!HasNext())
+ return null;
+
+ return _entities[_currentIndex++];
+ }
+
+ public void Reset()
+ {
+ _currentIndex = 0;
+ }
+ }
+}
+#nullable disable