Skip to content

Instantly share code, notes, and snippets.

@controlflow
Created August 1, 2019 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save controlflow/291b099c81789ebb2196bbec996a21b5 to your computer and use it in GitHub Desktop.
Save controlflow/291b099c81789ebb2196bbec996a21b5 to your computer and use it in GitHub Desktop.
private void ModifyItemsCount(int newCount)
{
if (myTail == null || myTail is FrugalLocalMarkerList<T>)
{
if (newCount == 0)
myTail = null;
else if (newCount == 1)
myTail = FrugalLocalMarkerList<T>.One;
else if (newCount == 2)
myTail = FrugalLocalMarkerList<T>.Two;
else
myTail = new FrugalLocalTailList<T>(newCount);
}
else
{
myTail.ItemsCount = newCount;
}
}
private void ModifyItemsCount(int newCount)
{
if (myTail == null || myTail is FrugalLocalMarkerList<T>)
{
myTail = newCount switch {
0 => null,
1 => FrugalLocalMarkerList<T>.One,
2 => FrugalLocalMarkerList<T>.Two,
_ => new FrugalLocalTailList<T>(newCount)
};
}
else
{
myTail.ItemsCount = newCount;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment