Skip to content

Commit

Permalink
Merge pull request #374 from linksplatform/fix_deleteall
Browse files Browse the repository at this point in the history
Make DeleteAll function great again
  • Loading branch information
FreePhoenix888 authored Mar 25, 2023
2 parents 9b87b39 + e37a4da commit 23f4871
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions cpp/Platform.Data.Doublets/ILinksExtensions.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,19 +109,6 @@ namespace Platform::Data::Doublets
return Delete(storage, linkToDelete, handler);
}

template<typename TStorage>
static void DeleteAll(TStorage& storage)
{
for (auto i { Count(storage) }; i > storage.Constants.Null; --i)
{
Delete(storage, i);
if (i - 1 != Count(storage))
{
i = Count(storage);
}
}
}

template<typename TStorage>
static typename TStorage::LinkAddressType First(const TStorage& storage)
{
Expand Down Expand Up @@ -699,9 +686,13 @@ namespace Platform::Data::Doublets
template<typename TStorage>
auto DeleteAll(TStorage& storage)
{
for (auto count = Count(storage); count != 0; count = Count(storage))
auto handler = [](typename TStorage::LinkType before, typename TStorage::LinkType substitution) {
return typename TStorage::LinkAddressType {};
};
auto any = storage.Constants.Any;
for (auto count = Count(storage); count != storage.Constants.Null; count = Count(storage))
{
DIRECT_METHOD_CALL(TStorage, storage, Delete,count);
DIRECT_METHOD_CALL(TStorage, storage, Delete, {count, any, any}, handler);
}
}

Expand Down

0 comments on commit 23f4871

Please sign in to comment.