예제 #1
0
        public void AddChild(
            TreeJoint <T> childJoint
            )
        {
            if (childJoint is null)
            {
                throw new ArgumentNullException(nameof(childJoint));
            }

            _children.Add(childJoint);
        }
예제 #2
0
        public TreeJoint(
            TreeJoint <T>?parent,
            T jointPayload
            )
        {
            if (jointPayload is null)
            {
                throw new ArgumentNullException(nameof(jointPayload));
            }

            Parent       = parent;
            JointPayload = jointPayload;
            _children    = new List <TreeJoint <T> >();
        }
예제 #3
0
        public bool TryFindInItsParents(
            Func <T, bool> predicate,
            [NotNullWhen(true)] out TreeJoint <T>?foundJoint
            )
        {
            if (predicate is null)
            {
                throw new ArgumentNullException(nameof(predicate));
            }

            if (Parent is null)
            {
                foundJoint = null;
                return(false);
            }

            return(Parent.TryFindInThisAndItsParents(predicate, out foundJoint));
        }