Skip to content

Commit 23f4871

Browse files
Merge pull request #374 from linksplatform/fix_deleteall
Make DeleteAll function great again
2 parents 9b87b39 + e37a4da commit 23f4871

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

cpp/Platform.Data.Doublets/ILinksExtensions.h

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,6 @@ namespace Platform::Data::Doublets
109109
return Delete(storage, linkToDelete, handler);
110110
}
111111

112-
template<typename TStorage>
113-
static void DeleteAll(TStorage& storage)
114-
{
115-
for (auto i { Count(storage) }; i > storage.Constants.Null; --i)
116-
{
117-
Delete(storage, i);
118-
if (i - 1 != Count(storage))
119-
{
120-
i = Count(storage);
121-
}
122-
}
123-
}
124-
125112
template<typename TStorage>
126113
static typename TStorage::LinkAddressType First(const TStorage& storage)
127114
{
@@ -699,9 +686,13 @@ namespace Platform::Data::Doublets
699686
template<typename TStorage>
700687
auto DeleteAll(TStorage& storage)
701688
{
702-
for (auto count = Count(storage); count != 0; count = Count(storage))
689+
auto handler = [](typename TStorage::LinkType before, typename TStorage::LinkType substitution) {
690+
return typename TStorage::LinkAddressType {};
691+
};
692+
auto any = storage.Constants.Any;
693+
for (auto count = Count(storage); count != storage.Constants.Null; count = Count(storage))
703694
{
704-
DIRECT_METHOD_CALL(TStorage, storage, Delete,count);
695+
DIRECT_METHOD_CALL(TStorage, storage, Delete, {count, any, any}, handler);
705696
}
706697
}
707698

0 commit comments

Comments
 (0)