Compare commits
1 Commits
03ebfa1321
...
61e2d39bee
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61e2d39bee |
|
|
@ -22,12 +22,12 @@ internal class PathTree<T> where T : class {
|
||||||
throw new Exception($"Found illegal catchall-wildcard in path: '{string.Join('/', path)}'");
|
throw new Exception($"Found illegal catchall-wildcard in path: '{string.Join('/', path)}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
var leafdata = unpackedLeafData[i] ?? throw new ArgumentNullException("Leafdata must not be null!");
|
var leafdata = unpackedLeafData[i];
|
||||||
rootNode.AddSuccessor(path, leafdata);
|
rootNode.AddSuccessor(path, leafdata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool TryGetPath(string reqPath, [MaybeNullWhen(false)] out T endpoint) {
|
internal bool TryGetPath(string reqPath, [MaybeNullWhen(false)] out T? endpoint) {
|
||||||
if (rootNode == null) {
|
if (rootNode == null) {
|
||||||
endpoint = null;
|
endpoint = null;
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -58,16 +58,16 @@ internal class PathTree<T> where T : class {
|
||||||
|
|
||||||
// return found path
|
// return found path
|
||||||
endpoint = currNode.leafData;
|
endpoint = currNode.leafData;
|
||||||
return endpoint != null;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Node {
|
private class Node {
|
||||||
public T? leafData = null; // null means that this is a node without a value (e.g. when it is just part of a path)
|
public T? leafData = null;
|
||||||
public Dictionary<string, Node>? next = null;
|
public Dictionary<string, Node>? next = null;
|
||||||
public Node? pathWildcardNext = null; // path wildcard
|
public Node? pathWildcardNext = null; // path wildcard
|
||||||
public Node? catchAllNext = null; // trailing-catchall wildcard
|
public Node? catchAllNext = null; // trailing-catchall wildcard
|
||||||
|
|
||||||
public void AddSuccessor(string[] segments, T newLeafData) {
|
public void AddSuccessor(string[] segments, T? newLeafData) {
|
||||||
if (segments.Length == 0) { // actually add the data to this node
|
if (segments.Length == 0) { // actually add the data to this node
|
||||||
Assert(leafData == null);
|
Assert(leafData == null);
|
||||||
leafData = newLeafData;
|
leafData = newLeafData;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user