/// <summary> /// Creates a new instance of a <see cref="OTBNode"/>. /// </summary> public OTBNode(OTBNodeType type, ReadOnlyArray <OTBNode> children, ReadOnlyMemory <byte> data) { if (children == null) { throw new ArgumentNullException(nameof(children)); } Type = type; Children = children; Data = data; }
/// <remarks>Start will be included in the data.</remarks> public void AddNodeBegin(int start, OTBNodeType type) { if (start < 0 || start > _serializedTreeData.Length) { throw new ArgumentOutOfRangeException(nameof(start)); } // Sanity check if (_nodeStarts.TryPeek(out var lastStart)) { if (start <= lastStart) { throw new InvalidOperationException(); } } _nodeStarts.Push(start); _childrenCounts.Push(0); _nodeTypes.Push(type); }