Added pools, IndexedFishMap, IndexedFishSet, fixed bugs related to FishTable.Remove, added Preview.png, various smaller additions, some refactoring too

This commit is contained in:
bbradson
2024-01-27 10:02:57 +01:00
parent cdf209eb02
commit af759661bd
38 changed files with 1879 additions and 642 deletions
@@ -0,0 +1,40 @@
// Copyright (c) 2023 bradson
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
using System.Runtime.CompilerServices;
using System.Text;
using JetBrains.Annotations;
namespace FisheryLib.Pools;
[UsedImplicitly(ImplicitUseTargetFlags.WithMembers)]
[InterpolatedStringHandler]
public record struct PooledStringBuilderHandler : IDisposable
{
private PooledIList<List<char>> _chars;
public PooledStringBuilderHandler(int literalLength, int formattedCount)
{
_chars = new();
_chars.List.EnsureCapacity(literalLength + (formattedCount * 8));
}
public void AppendLiteral(string s) => _chars.List.Add(s);
public void AppendFormatted<T>(T t)
{
if (t != null)
_chars.List.Add(t.ToString());
}
public StringBuilder AppendToStringBuilder(StringBuilder destination)
{
destination.Append(_chars.List);
Dispose();
return destination;
}
public void Dispose() => _chars.Dispose();
}