Skip to content

Commit

Permalink
Move garbage collection extensions to Data.Doublets
Browse files Browse the repository at this point in the history
  • Loading branch information
FreePhoenix888 committed Feb 19, 2023
1 parent 00608fa commit b61de4b
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions csharp/Platform.Data.Doublets.Sequences/LinksExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,5 @@ public static void UseUnicode<TLinkAddress>(this ILinks<TLinkAddress> links) whe
{
UnicodeMap<TLinkAddress>.InitNew(links);
}

#region Garbage Collection
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsGarbage<TLinkAddress>(this ILinks<TLinkAddress> links, TLinkAddress link) where TLinkAddress : struct, IUnsignedNumber<TLinkAddress>, IComparisonOperators<TLinkAddress, TLinkAddress, bool>
{
return !links.IsPartialPoint(link) && links.Count(links.Constants.Any, link) == TLinkAddress.Zero && links.Count(links.Constants.Any, links.Constants.Any, link) == TLinkAddress.Zero;
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ClearGarbage<TLinkAddress>(this ILinks<TLinkAddress> links, TLinkAddress link) where TLinkAddress : struct, IUnsignedNumber<TLinkAddress>, IComparisonOperators<TLinkAddress, TLinkAddress, bool>
{
ClearGarbage(links, link, links.IsGarbage);
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ClearGarbage<TLinkAddress>(this ILinks<TLinkAddress> links, TLinkAddress link, Func<TLinkAddress, bool> getIsGarbage) where TLinkAddress : struct, IUnsignedNumber<TLinkAddress>, IComparisonOperators<TLinkAddress, TLinkAddress, bool>
{
if (getIsGarbage(link))
{
var contents = new Link<TLinkAddress>(links.GetLink(link));
links.Delete(link);
links.ClearGarbage(contents.Source);
links.ClearGarbage(contents.Target);
}
}

#endregion
}
}

0 comments on commit b61de4b

Please sign in to comment.