Example #1
0
    public Optional <T_ElementType> findElement(ElementPredicate inPredicate)
    {
        Optional <int> theIndex = findIndex(inPredicate);

        return(!theIndex.isSet() ? new Optional <T_ElementType>() :
               new Optional <T_ElementType>(this[theIndex.getValue()]));
    }
            public override bool ForEachElement(Debugger debugger, string name, ElementPredicate elementPredicate)
            {
                int size1, size2;

                LoadSizes(debugger, name, out size1, out size2);

                for (int i = 0; i < size1; ++i)
                {
                    string elName = "(*(" + name + ".m_first + " + i + "))";
                    if (!elementPredicate(elName))
                    {
                        return(false);
                    }
                }

                for (int i = 0; i < size2; ++i)
                {
                    string elName = "(*(" + name + ".m_buff + " + i + "))";
                    if (!elementPredicate(elName))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            private bool ForEachElementRecursive(Debugger debugger, string nodeName, ElementPredicate elementPredicate)
            {
                Expression expr = debugger.GetExpression("(" + nodeName + "->_Isnil == false)");

                if (expr.IsValidValue && (expr.Value == "true" || expr.Value == "1"))
                {
                    return(ForEachElementRecursive(debugger, nodeName + "->_Left", elementPredicate) &&
                           elementPredicate(nodeName + "->_Myval") &&
                           ForEachElementRecursive(debugger, nodeName + "->_Right", elementPredicate));
                }
                return(true); // ignore leaf
            }
            public override bool ForEachElement(Debugger debugger, string name, ElementPredicate elementPredicate)
            {
                int size = LoadSize(debugger, name);

                if (size <= 0)
                {
                    return(true);
                }

                string nodeName = HeadStr(name);

                return(ForEachElementRecursive(debugger, nodeName, elementPredicate));
            }
Example #5
0
 public void collectAll(ref FastArray <T_ElementType> outElements, ElementPredicate inPredicate)
 {
     if (null == inPredicate)
     {
         return;
     }
     foreach (T_ElementType theElement in this)
     {
         if (!inPredicate(theElement))
         {
             continue;
         }
         outElements.add(theElement);
     }
 }
            public override bool ForEachElement(Debugger debugger, string name, ElementPredicate elementPredicate)
            {
                int    size    = this.LoadSize(debugger, name);
                string rawName = this.RandomAccessName(name);

                for (int i = 0; i < size; ++i)
                {
                    string elName = this.RandomAccessElementName(rawName, i);
                    if (!elementPredicate(elName))
                    {
                        return(false);
                    }
                }
                return(true);
            }
            public override bool ForEachElement(Debugger debugger, string name, ElementPredicate elementPredicate)
            {
                int size = this.LoadSize(debugger, name);

                string nodeName = HeadStr(name) + "->_Next";

                for (int i = 0; i < size; ++i, nodeName += "->_Next")
                {
                    string elName = nodeName + "->_Myval";
                    if (!elementPredicate(elName))
                    {
                        return(false);
                    }
                }
                return(true);
            }
Example #8
0
    public void iterateWithRemove(ElementPredicate inPredicate, bool inUseSwapRemove = false)
    {
        int theIndex = 0;

        while (theIndex < getSize())
        {
            bool theDoRemove = inPredicate.Invoke(_elements[theIndex]);
            if (theDoRemove)
            {
                removeElementAt(theIndex, inUseSwapRemove);
            }
            else
            {
                ++theIndex;
            }
        }
    }
            public override bool ForEachElement(Debugger debugger, string name, ElementPredicate elementPredicate)
            {
                int size = this.LoadSize(debugger, name);

                string nodeName = name + ".head";

                for (int i = 0; i < size; ++i)
                {
                    string elName = nodeName + ".item";
                    if (!elementPredicate(elName))
                    {
                        return(false);
                    }
                    nodeName = nodeName + ".next";
                }
                return(true);
            }
Example #10
0
    //-Find
    public Optional <int> findIndex(ElementPredicate inPredicate)
    {
        if (null == inPredicate)
        {
            return(new Optional <int>());
        }
        XUtils.check(null != inPredicate);

        int theIndex = 0;

        foreach (T_ElementType theElement in this)
        {
            if (inPredicate.Invoke(theElement))
            {
                return(new Optional <int>(theIndex));
            }
            ++theIndex;
        }

        return(new Optional <int>());
    }
 abstract public bool ForEachElement(Debugger debugger, string name, ElementPredicate elementPredicate);