diff --git a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenList`1.Enumerable.g.cs b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenList`1.Enumerable.g.cs
index 5f28270..28dace5 100644
--- a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenList`1.Enumerable.g.cs
+++ b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenList`1.Enumerable.g.cs
@@ -1 +1,38 @@
-
\ No newline at end of file
+// 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.
+//
+
+#nullable enable
+
+namespace Tsu.Trees.RedGreen.Sample.Internal
+{
+ internal partial struct SampleList where TNode : global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode
+ {
+ internal struct Enumerator
+ {
+ private readonly SampleList _list;
+ private int _index;
+
+ internal Enumerator(SampleList list)
+ {
+ _list = list;
+ _index = -1;
+ }
+
+ public bool MoveNext()
+ {
+ var newIndex = _index + 1;
+ if (newIndex < _list.Count)
+ {
+ _index = newIndex;
+ return true;
+ }
+
+ return false;
+ }
+
+ public TNode Current => _list[_index]!;
+ }
+ }
+}
diff --git a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenList`1.g.cs b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenList`1.g.cs
index 5f28270..08689aa 100644
--- a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenList`1.g.cs
+++ b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenList`1.g.cs
@@ -1 +1,145 @@
-
\ No newline at end of file
+// 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.
+//
+
+#nullable enable
+
+using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+
+namespace Tsu.Trees.RedGreen.Sample.Internal
+{
+ internal readonly partial struct SampleList : global::System.IEquatable>
+ where TNode : global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode
+ {
+ private readonly global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? _node;
+
+ internal SampleList(global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? node)
+ {
+ _node = node;
+ }
+
+ internal global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? Node => _node;
+
+ public int Count => _node == null ? 0 : (_node.IsList ? _node.SlotCount : 1);
+
+ public TNode? this[int index]
+ {
+ get
+ {
+ if (_node == null)
+ {
+ return null;
+ }
+ else if (_node.IsList)
+ {
+ global::System.Diagnostics.Debug.Assert(index >= 0);
+ global::System.Diagnostics.Debug.Assert(index <= _node.SlotCount);
+
+ return (TNode?) _node.GetSlot(index);
+ }
+ else if (index == 0)
+ {
+ return (TNode?) _node;
+ }
+ else
+ {
+ throw new global::System.InvalidOperationException("The program has reached a state that was thought to be unreachable.");
+ }
+ }
+ }
+
+ internal TNode GetRequiredItem(int index)
+ {
+ var node = this[index];
+ global::System.Diagnostics.Debug.Assert(node is object);
+ return node!;
+ }
+
+ internal global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode? ItemUntyped(int index)
+ {
+ global::System.Diagnostics.Debug.Assert(_node is not null);
+ var node = _node!;
+ if (node.IsList)
+ {
+ return node.GetSlot(index);
+ }
+
+ global::System.Diagnostics.Debug.Assert(index == 0);
+ return node;
+ }
+
+ public bool Any() => _node != null;
+
+ public bool Any(global::Tsu.Trees.RedGreen.Sample.SampleKind kind)
+ {
+ foreach (var element in this)
+ {
+ if (element.Kind == kind)
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ internal TNode[] Nodes
+ {
+ get
+ {
+ var arr = new TNode[Count];
+ for (int i = 0; i < Count; i++)
+ {
+ arr[i] = GetRequiredItem(i);
+ }
+ return arr;
+ }
+ }
+
+ public TNode? Last
+ {
+ get
+ {
+ global::System.Diagnostics.Debug.Assert(_node is not null);
+ var node = _node!;
+ if (node.IsList)
+ {
+ return (TNode?) node.GetSlot(node.SlotCount - 1);
+ }
+
+ return (TNode?) node;
+ }
+ }
+
+ public Enumerator GetEnumerator() => new(this);
+
+ internal void CopyTo(int offset, global::Tsu.Trees.RedGreen.Sample.Internal.GreenNode[] array, int arrayOffset, int count)
+ {
+ for (int i = 0; i < count; i++)
+ {
+ array[arrayOffset + i] = GetRequiredItem(i + offset);
+ }
+ }
+
+ public static bool operator ==(SampleList left, SampleList right) =>
+ left._node == right._node;
+
+ public static bool operator !=(SampleList left, SampleList right) =>
+ left._node != right._node;
+
+ public bool Equals(SampleList other) => _node == other._node;
+
+ public override bool Equals(object? obj) => (obj is SampleList list) && Equals(list);
+
+ public override int GetHashCode() => _node != null ? _node.GetHashCode() : 0;
+
+ public static implicit operator SampleList(TNode node) => new(node);
+
+ public static implicit operator SampleList(SampleList nodes) => new(nodes._node);
+
+ public static implicit operator SampleList(SampleList nodes) => new(nodes.Node);
+ }
+}
diff --git a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenRoot.g.cs b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenRoot.g.cs
index 75e4f31..f82ee42 100644
--- a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenRoot.g.cs
+++ b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenRoot.g.cs
@@ -1,4 +1,7 @@
-//
+// 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.
+//
#nullable enable
diff --git a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenWalker.g.cs b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenWalker.g.cs
index 581a274..b7de85f 100644
--- a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenWalker.g.cs
+++ b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/Internal/GreenWalker.g.cs
@@ -1,4 +1,7 @@
-//
+// 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.
+//
#nullable enable
diff --git a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/RedBase.g.cs b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/RedBase.g.cs
index 781d42f..6682d20 100644
--- a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/RedBase.g.cs
+++ b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/RedBase.g.cs
@@ -1,4 +1,7 @@
-//
+// 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.
+//
#nullable enable
diff --git a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/RedWalker.g.cs b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/RedWalker.g.cs
index 03a6383..5436245 100644
--- a/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/RedWalker.g.cs
+++ b/Tsu.Trees.RedGreen/sample/Generated/Tsu.Trees.RedGreen/Tsu.Trees.RedGreen.SourceGenerator.Generator/Sample/RedWalker.g.cs
@@ -1,4 +1,7 @@
-//
+// 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.
+//
#nullable enable
diff --git a/Tsu.Trees.RedGreen/src/Templates/Internal/GreenList`1.Enumerable.sbn-cs b/Tsu.Trees.RedGreen/src/Templates/Internal/GreenList`1.Enumerable.sbn-cs
index 2bc4c62..dad7f72 100644
--- a/Tsu.Trees.RedGreen/src/Templates/Internal/GreenList`1.Enumerable.sbn-cs
+++ b/Tsu.Trees.RedGreen/src/Templates/Internal/GreenList`1.Enumerable.sbn-cs
@@ -1,17 +1,21 @@
{{~ 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.
+//
-namespace {{ green_list.namespace | not_global }}
+#nullable enable
+
+namespace {{ green_base.namespace | not_global }}
{
- {{ green_list.accessibility }} partial struct {{ green_list.name }} where TNode : {{ green_base.csharp }}
+ {{ green_base.accessibility }} partial struct {{ suffix }}List where TNode : {{ green_base.csharp }}
{
- {{ green_list.accessibility }} struct Enumerator
+ {{ green_base.accessibility }} struct Enumerator
{
- private readonly {{ green_list.name }} _list;
+ private readonly {{ suffix }}List _list;
private int _index;
- internal Enumerator({{ green_list.name }} list)
+ {{ green_base.accessibility }} Enumerator({{ suffix }}List list)
{
_list = list;
_index = -1;
diff --git a/Tsu.Trees.RedGreen/src/Templates/Internal/GreenList`1.sbn-cs b/Tsu.Trees.RedGreen/src/Templates/Internal/GreenList`1.sbn-cs
index 087f143..2b50a20 100644
--- a/Tsu.Trees.RedGreen/src/Templates/Internal/GreenList`1.sbn-cs
+++ b/Tsu.Trees.RedGreen/src/Templates/Internal/GreenList`1.sbn-cs
@@ -1,6 +1,7 @@
{{~ 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.
//
#nullable enable
@@ -9,14 +10,14 @@ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
-namespace {{ green_list.namespace | not_global }}
+namespace {{ green_base.namespace | not_global }}
{
- {{ green_list.accessibility }} readonly partial struct {{ green_list.name }} : global::System.IEquatable<{{ green_list.name }}>
+ {{ green_base.accessibility }} readonly partial struct {{ suffix }}List : global::System.IEquatable<{{ suffix }}List>
where TNode : {{ green_base.csharp | not_null }}
{
private readonly {{ green_base.csharp | not_null }}? _node;
- internal {{ green_list.name }}({{ green_base.csharp | not_null }}? node)
+ {{ green_base.accessibility }} {{ suffix }}List({{ green_base.csharp | not_null }}? node)
{
_node = node;
}
@@ -124,23 +125,23 @@ namespace {{ green_list.namespace | not_global }}
}
}
- public static bool operator ==({{ green_list.name }} left, {{ green_list.name }} right) =>
+ public static bool operator ==({{ suffix }}List left, {{ suffix }}List right) =>
left._node == right._node;
- public static bool operator !=({{ green_list.name }} left, {{ green_list.name }} right) =>
+ public static bool operator !=({{ suffix }}List left, {{ suffix }}List right) =>
left._node != right._node;
- public bool Equals({{ green_list.name }} other) => _node == other._node;
+ public bool Equals({{ suffix }}List other) => _node == other._node;
- public override bool Equals(object? obj) => (obj is {{ green_list.name }} list) && Equals(list);
+ public override bool Equals(object? obj) => (obj is {{ suffix }}List list) && Equals(list);
public override int GetHashCode() => _node != null ? _node.GetHashCode() : 0;
- public static implicit operator {{ green_list.name }}(TNode node) => new(node);
+ public static implicit operator {{ suffix }}List(TNode node) => new(node);
- public static implicit operator {{ green_list.name }}({{ green_list.name }}<{{ green_base.csharp }}> nodes) => new(nodes._node);
+ public static implicit operator {{ suffix }}List({{ suffix }}List<{{ green_base.csharp }}> nodes) => new(nodes._node);
- public static implicit operator {{ green_list.name }}<{{ green_base.csharp }}>({{ green_list.name }} nodes) => new(nodes.Node);
+ public static implicit operator {{ suffix }}List<{{ green_base.csharp }}>({{ suffix }}List nodes) => new(nodes.Node);
}
}
{{~ end ~}}
\ No newline at end of file
diff --git a/Tsu.Trees.RedGreen/src/Templates/Internal/GreenRoot.sbn-cs b/Tsu.Trees.RedGreen/src/Templates/Internal/GreenRoot.sbn-cs
index ee9dc14..748fb83 100644
--- a/Tsu.Trees.RedGreen/src/Templates/Internal/GreenRoot.sbn-cs
+++ b/Tsu.Trees.RedGreen/src/Templates/Internal/GreenRoot.sbn-cs
@@ -1,3 +1,6 @@
+// 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.
//
#nullable enable
diff --git a/Tsu.Trees.RedGreen/src/Templates/Internal/GreenWalker.sbn-cs b/Tsu.Trees.RedGreen/src/Templates/Internal/GreenWalker.sbn-cs
index 72b1b39..7aa841d 100644
--- a/Tsu.Trees.RedGreen/src/Templates/Internal/GreenWalker.sbn-cs
+++ b/Tsu.Trees.RedGreen/src/Templates/Internal/GreenWalker.sbn-cs
@@ -1,3 +1,6 @@
+// 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.
//
#nullable enable
diff --git a/Tsu.Trees.RedGreen/src/Templates/RedBase.sbn-cs b/Tsu.Trees.RedGreen/src/Templates/RedBase.sbn-cs
index 4c7a70f..f5d0a88 100644
--- a/Tsu.Trees.RedGreen/src/Templates/RedBase.sbn-cs
+++ b/Tsu.Trees.RedGreen/src/Templates/RedBase.sbn-cs
@@ -1,3 +1,6 @@
+// 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.
//
#nullable enable
diff --git a/Tsu.Trees.RedGreen/src/Templates/RedWalker.sbn-cs b/Tsu.Trees.RedGreen/src/Templates/RedWalker.sbn-cs
index 296b50e..749afde 100644
--- a/Tsu.Trees.RedGreen/src/Templates/RedWalker.sbn-cs
+++ b/Tsu.Trees.RedGreen/src/Templates/RedWalker.sbn-cs
@@ -1,3 +1,6 @@
+// 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.
//
#nullable enable