Пример #1
0
        public PxEntry BinarySearchFirst(Func <PxEntry, int> elementDepth)
        {
            PxEntry sequ = this;
            var     typ  = sequ.typ;

            if (typ.Vid != PTypeEnumeration.sequence)
            {
                throw new Exception("Function FindZero can't be applied to the type with vid=" + typ.Vid);
            }
            PTypeSequence mts  = (PTypeSequence)sequ.typ;
            PType         tel  = mts.ElementType;
            long          llen = sequ.Count();

            if (llen == 0)
            {
                throw new Exception("No elements to FindZero");
            }
            var first_el    = sequ.Element(0);
            var first_depth = elementDepth(first_el);

            if (first_depth == 0)
            {
                return(first_el);
            }
            PxEntry found = BSF(first_el, llen, elementDepth);

            //if (found.offset == long.MinValue) throw new Exception("Zero element did't foound by FindZero()");
            return(found);
        }
Пример #2
0
        public IEnumerable <PxEntry> BinarySearchAll(Func <PxEntry, int> elementDepth)
        {
            PxEntry sequ = this;
            var     typ  = sequ.typ;

            if (typ.Vid != PTypeEnumeration.sequence)
            {
                throw new Exception("Function FindZero can't be applied to the type with vid=" + typ.Vid);
            }
            PTypeSequence mts  = (PTypeSequence)sequ.typ;
            PType         tel  = mts.ElementType;
            long          llen = sequ.Count();

            if (llen > 0)
            {
                var elementFrom = sequ.Element(0);
                foreach (var pe in BinarySearchInside(elementFrom, llen, elementDepth))
                {
                    yield return(pe);
                }
            }
        }