private Component InsertSingleNode(Component root, SingleComponent singleNode) { if (root == null) { Root = singleNode; Root = Root as SingleComponent; return(Root); } //Try to put the single node on the left side of tree as much as possible if (root is Negation || root is Predicate) { if (root.LeftNode == null) { root.LeftNode = singleNode; root.LeftNode.Parent = root; return(singleNode.Parent); } //If both left and right node were full, insert it to the parent return(root.Parent != null?InsertNode(root.Parent, singleNode) : singleNode.Parent); } else { if (root.LeftNode == null) { root.LeftNode = singleNode; root.LeftNode.Parent = root; return(singleNode.Parent); } if (root.RightNode == null) { root.RightNode = singleNode; root.RightNode.Parent = root; return(singleNode.Parent); } //If both left and right node were full, insert it to the parent if (root.Parent != null) { return(InsertNode(root.Parent, singleNode)); } //Specifically be useful for DNF where tree be created from bottom to top var newRoot = new Conjunction(); root.Parent = newRoot; newRoot.LeftNode = root; root = newRoot; root.RightNode = singleNode; Root = root; return(singleNode.Parent); } }
protected override void AddSpecifiedAttributes() { AddAttribute(RoutingMode); if (Start != null) AddAttribute(Start); if (Destination != null) AddAttribute(Destination); AddAttribute(PropertyHelper.GetDescription(() => Ranges), string.Join(",", Ranges)); AddAttribute(PropertyHelper.GetDescription(() => RangeType), EnumHelper.GetDescription(RangeType)); if (JsonAttributes != null) AddAttribute(JsonAttributes); else AddAttribute(new JsonRepresentation(JsonAttribute.Include_TypeElement, JsonAttribute.UsePluralNamingForCollections, JsonAttribute.SupressJsonResponseObjectWrapper)); if (ConsumptionModel != null) AddAttribute(ConsumptionModel); if (CustomConsumptionDetails != null) AddAttribute(CustomConsumptionDetails); if (RequestId != null) AddAttribute(PropertyHelper.GetDescription(() => RequestId), RequestId); if (SingleComponent != null) AddAttribute(PropertyHelper.GetDescription(() => SingleComponent), SingleComponent.ToString().ToLower()); if (Resolution != null) AddAttribute(PropertyHelper.GetDescription(() => Resolution), Resolution.ToString()); if (MaxPoints != null) AddAttribute(PropertyHelper.GetDescription(() => MaxPoints), MaxPoints.ToString()); if (Quality != null) AddAttribute(PropertyHelper.GetDescription(() => Quality), Quality.ToString()); if (Departure != null) AddAttribute(PropertyHelper.GetDescription(() => Departure), ((DateTime)Departure).ToString("s")); if (Arrival != null) AddAttribute(PropertyHelper.GetDescription(() => Arrival), ((DateTime)Arrival).ToString("s")); if (JsonCallback != null) AddAttribute(PropertyHelper.GetDescription(() => JsonCallback), JsonCallback); if (TruckType != null) AddAttribute(PropertyHelper.GetDescription(() => TruckType), EnumHelper.GetDescription(TruckType)); if (TrailersCount != null) AddAttribute(PropertyHelper.GetDescription(() => TrailersCount), TrailersCount.ToString()); if (ShippedHazardousGoods != null) AddAttribute(PropertyHelper.GetDescription(() => ShippedHazardousGoods), string.Join(",", ShippedHazardousGoods.Select(sg => EnumHelper.GetDescription(sg)))); if (LimitedWeight != null) AddAttribute(PropertyHelper.GetDescription(() => LimitedWeight), LimitedWeight.Value.ToString(HereAPISession.Culture)); if (WeightPerAxle != null) AddAttribute(PropertyHelper.GetDescription(() => WeightPerAxle), WeightPerAxle.Value.ToString(HereAPISession.Culture)); if (Height != null) AddAttribute(PropertyHelper.GetDescription(() => Height), Height.Value.ToString(HereAPISession.Culture)); if (Width != null) AddAttribute(PropertyHelper.GetDescription(() => Width), Width.Value.ToString(HereAPISession.Culture)); if (Length != null) AddAttribute(PropertyHelper.GetDescription(() => Length), Length.Value.ToString(HereAPISession.Culture)); if (TunnelCategory != null) AddAttribute(PropertyHelper.GetDescription(() => TunnelCategory), EnumHelper.GetDescription(TunnelCategory)); }
public void SingleComponentTest() => Assert.IsTrue(SingleComponent.Assert(ITERATION_CNT));