Ejemplo n.º 1
0
        public OperatorBlueprint clone()
        {
            OperatorBlueprint cloned;

            cloned = new OperatorBlueprint(cloneTreeElement(this.rootTreeElement), deepcopyPaths(this.pathsToFreeOperators));

            return(cloned);
        }
Ejemplo n.º 2
0
        public static OperatorPlan instantiateBlueprint(OperatorBlueprint blueprint)
        {
            OperatorPlan resultPlan;

            resultPlan = new OperatorPlan();
            resultPlan.rootTreeElement = instantiateBlueprintTreeRecursive(blueprint.rootTreeElement);

            return(resultPlan);
        }
Ejemplo n.º 3
0
        /**
         *
         * only used for (re)filling
         */
        public void add(OperatorBlueprint value, float priority)
        {
            QueueElement element;

            System.Diagnostics.Debug.Assert(queue.Count <= size);

            element           = new QueueElement();
            element.priority  = priority;
            element.blueprint = value;

            if (queue.Count == size)
            {
                // replace the last element with the new element
                queue[queue.Count - 1] = element;
                return;
            }
            // else

            queue.Add(element);
        }
Ejemplo n.º 4
0
        public static OperatorBlueprint compose(OperatorBlueprint orginal, List <int> pathInOrginal, OperatorBlueprint composeWith, EnumReplace replace)
        {
            OperatorBlueprint result;
            TreeElement       currentTreeElement;

            result = orginal.clone();

            if (replace == EnumReplace.YES)
            {
                List <int> pathWithoutLast = pathInOrginal.GetRange(0, pathInOrginal.Count - 1);
                int        lastPathIndex   = pathInOrginal[pathInOrginal.Count - 1];

                // check if the pathInOrginal is one of pathToFreeOperators, if this is the case, remove it
                int pathToFreeOperatorsI;

                for (pathToFreeOperatorsI = 0; pathToFreeOperatorsI < result.pathsToFreeOperators.Count; pathToFreeOperatorsI++)
                {
                    List <int> pathsToFreeOperator;

                    pathsToFreeOperator = result.pathsToFreeOperators[pathToFreeOperatorsI];

                    if (ListTools.isListTheSameInt(pathsToFreeOperator, pathInOrginal))
                    {
                        result.pathsToFreeOperators.RemoveAt(pathToFreeOperatorsI);
                        pathToFreeOperatorsI--;
                        continue;
                    }
                }

                // include path to free operators from composeWith
                List <List <int> > pathsWithAppendedPath = appendPathsToPath(pathInOrginal, composeWith.pathsToFreeOperators);
                result.pathsToFreeOperators.AddRange(pathsWithAppendedPath);

                // walk the path in the orginal/result
                // without the last because we replace it
                currentTreeElement = walkTreeElementByPath(result.rootTreeElement, pathWithoutLast);

                currentTreeElement.childrens[lastPathIndex] = cloneTreeElement(composeWith.rootTreeElement);
            }
            else if (replace == EnumReplace.NO)
            {
                // TODO
                throw new NotImplementedException();

                // walk the path in the orginal/result
                // without the last because we replace it
                //currentTreeElement = walkTreeElementByPath(result.rootTreeElement, pathInOrginal);

                // must be a branch because we add the other plan of the operator/scaffold
                currentTreeElement.type = TreeElement.EnumType.BRANCH;

                // add
                foreach (TreeElement iterationChildElement in composeWith.rootTreeElement.childrens)
                {
                    currentTreeElement.childrens.Add(cloneTreeElement(iterationChildElement));
                }
            }
            else
            {
                throw new Exception("internal error");
            }

            return(result);
        }
Ejemplo n.º 5
0
 public static int countDummiesRecursive(OperatorBlueprint blueprint)
 {
     return(countDummiesOfTreeRecursive(blueprint.rootTreeElement));
 }