Пример #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));
        }