-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3ec51c
commit 1c277f2
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
Tsu.Trees.RedGreen/src/Templates/Internal/GreenListBuilder`1.sbn-cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{{~ if create_lists ~}} | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// Modified by the Tsu (https://github.com/GGG-KILLER/Tsu) project for embedding into other projects. | ||
// <auto-generated /> | ||
|
||
#nullable enable | ||
|
||
namespace {{ green_base.namespace | not_global }} | ||
{ | ||
internal readonly struct {{ suffix }}ListBuilder<TNode> where TNode : {{ green_base.csharp | not_null }} | ||
{ | ||
private readonly {{ suffix }}ListBuilder _builder; | ||
|
||
public {{ suffix }}ListBuilder(int size) | ||
: this(new {{ suffix }}ListBuilder(size)) | ||
{ | ||
} | ||
|
||
public static {{ suffix }}ListBuilder<TNode> Create() => new(8); | ||
|
||
internal {{ suffix }}ListBuilder({{ suffix }}ListBuilder builder) | ||
{ | ||
_builder = builder; | ||
} | ||
|
||
public bool IsNull => _builder == null; | ||
|
||
public int Count => _builder.Count; | ||
|
||
public TNode? this[int index] | ||
{ | ||
get => (TNode?) _builder[index]; | ||
|
||
set => _builder[index] = value; | ||
} | ||
|
||
public void Clear() => _builder.Clear(); | ||
|
||
public {{ suffix }}ListBuilder<TNode> Add(TNode node) | ||
{ | ||
_builder.Add(node); | ||
return this; | ||
} | ||
|
||
public void AddRange(TNode[] items, int offset, int length) => | ||
_builder.AddRange(items, offset, length); | ||
|
||
public void AddRange({{ suffix }}List<TNode> nodes) => _builder.AddRange(nodes); | ||
|
||
public void AddRange({{ suffix }}List<TNode> nodes, int offset, int length) => | ||
_builder.AddRange(nodes, offset, length); | ||
|
||
public bool Any({{ kind_enum.csharp | not_null }} kind) => _builder.Any(kind); | ||
|
||
public {{ suffix }}List<TNode> ToList() => _builder.ToList(); | ||
|
||
public {{ green_base.csharp | not_null }}? ToListNode() => _builder.ToListNode(); | ||
|
||
public static implicit operator {{ suffix }}ListBuilder({{ suffix }}ListBuilder<TNode> builder) => builder._builder; | ||
|
||
public static implicit operator {{ suffix }}List<TNode>({{ suffix }}ListBuilder<TNode> builder) | ||
{ | ||
if (builder._builder != null) | ||
{ | ||
return builder.ToList(); | ||
} | ||
|
||
return default; | ||
} | ||
|
||
public {{ suffix }}List<TDerived> ToList<TDerived>() where TDerived : {{ green_base.csharp | not_null }} => | ||
new(ToListNode()); | ||
} | ||
} | ||
{{~ end ~}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters