From 2ca4e3aa610e93cb22fdb19633f0a170fc178689 Mon Sep 17 00:00:00 2001 From: Anton Tarasenko Date: Sat, 2 Jul 2022 16:48:24 +0700 Subject: [PATCH] Change `ArrayListIterator` to use filter method --- sources/Data/Collections/ArrayListIterator.uc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sources/Data/Collections/ArrayListIterator.uc b/sources/Data/Collections/ArrayListIterator.uc index ee8fed2..9e42991 100644 --- a/sources/Data/Collections/ArrayListIterator.uc +++ b/sources/Data/Collections/ArrayListIterator.uc @@ -22,9 +22,12 @@ class ArrayListIterator extends Iter; var private ArrayList relevantCollection; var private int currentIndex; +var private bool skipNoneReferences; + protected function Finalizer() { relevantCollection = none; + skipNoneReferences = false; } public function bool Initialize(Collection relevantArray) @@ -37,10 +40,15 @@ public function bool Initialize(Collection relevantArray) return true; } -public function Iter Next(optional bool skipNone) +public function LeaveOnlyNotNone() +{ + skipNoneReferences = true; +} + +public function Iter Next() { local int collectionLength; - if (!skipNone) + if (!skipNoneReferences) { currentIndex += 1; return self;