Ejemplo n.º 1
0
        Tuple <IIndex <c>, VectorConstruction> IIndexBuilder.Search <c, d>(Tuple <IIndex <c>, VectorConstruction> _arg8, IVector <d> searchVector, d searchValue)
        {
            Tuple <IIndex <c>, VectorConstruction> tuple = _arg8;
            VectorConstruction vectorConstruction        = tuple.Item2;
            IIndex <c>         index1   = tuple.Item1;
            List <c>           cList    = new List <c>();
            List <long>        longList = new List <long>();
            int index2 = 0;
            int count  = index1.Keys.Count;
            int length = (int)searchVector.Length;
            int num    = (count >= length ? length : count) - 1;

            if (num >= index2)
            {
                do
                {
                    d optionalValue = searchVector.GetValue((long)index2);
                    if ((!optionalValue.HasValue ? 0 : (LanguagePrimitives.HashCompare.GenericEqualityIntrinsic <d>((M0)optionalValue.Value, (M0)searchValue) ? 1 : 0)) != 0)
                    {
                        cList.Add(index1.Keys[index2]);
                        longList.Add((long)index2);
                    }
                    ++index2;
                }while (index2 != num + 1);
            }
            LinearIndex <c>         linearIndex      = new LinearIndex <c>(System.Array.AsReadOnly <c>(ArrayModule.OfSeq <c>((IEnumerable <c>)cList)), (IIndexBuilder)this, (FSharpOption <bool>)null);
            IEnumerable <long>      indices          = (IEnumerable <long>)SeqModule.Map <long, long>((Func <M0, M1>) new LinearIndex.range(), (IEnumerable <M0>)longList);
            RangeRestriction <long> rangeRestriction = VectorHelpers.RangeRestriction.ofSeq((long)longList.Count, indices);

            return(new Tuple <IIndex <c>, VectorConstruction>((IIndex <c>)linearIndex, VectorConstruction.NewGetRange(vectorConstruction, rangeRestriction)));
        }
Ejemplo n.º 2
0
        internal Tuple <LinearIndex <a>, VectorConstruction> asLinearIndex <a>(IIndex <a> index, VectorConstruction vector)
        {
            LinearIndex <a> linearIndex = index as LinearIndex <a>;

            if (linearIndex != null)
            {
                return(new Tuple <LinearIndex <a>, VectorConstruction>(linearIndex, vector));
            }
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >)SeqModule.MapIndexed <KeyValuePair <a, long>, Tuple <long, long> >((Func <int, Func <M0, M1> >) new LinearIndex.relocs <a>(), (IEnumerable <M0>)index.Mappings);
            VectorConstruction vectorConstruction    = VectorConstruction.NewRelocate(vector, index.KeyCount, tuples);

            return(new Tuple <LinearIndex <a>, VectorConstruction>(new LinearIndex <a>(System.Array.AsReadOnly <a>(ArrayModule.OfSeq <a>((IEnumerable <a>)SeqModule.Map <KeyValuePair <a, long>, a>((Func <M0, M1>) new LinearIndex.clo <a>(), (IEnumerable <M0>)index.Mappings))), LinearIndexBuilder.Instance, (FSharpOption <bool>)null), vectorConstruction));
        }
Ejemplo n.º 3
0
        Tuple <IIndex <TNewKey>, VectorConstruction> IIndexBuilder.WithIndex <K, TNewKey>(IIndex <K> index1, IVector <TNewKey> indexVector, VectorConstruction vector)
        {
            Tuple <TNewKey, long>[] array       = (Tuple <TNewKey, long>[])SeqModule.ToArray <Tuple <TNewKey, long> >((IEnumerable <M0>) new LinearIndex.newKeys <TNewKey, K>(index1, indexVector, new KeyValuePair <K, long>(), (Tuple <K, long>)null, new long(), default(K), new TNewKey(), (IEnumerator <KeyValuePair <K, long> >)null, 0, (Tuple <TNewKey, long>)null));
            LinearIndex <TNewKey>   linearIndex = new LinearIndex <TNewKey>(System.Array.AsReadOnly <TNewKey>((TNewKey[])ArrayModule.OfSeq <TNewKey>((IEnumerable <M0>)SeqModule.Map <Tuple <TNewKey, long>, TNewKey>((Func <M0, M1>) new LinearIndex.newIndex <TNewKey>(), (IEnumerable <M0>)array))), (IIndexBuilder)this, (FSharpOption <bool>)null);
            long keyCount = ((IIndex <TNewKey>)linearIndex).KeyCount;

            LinearIndex.relocations relocations5178 = new LinearIndex.relocations();
            long   lo  = 0;
            long   hi  = keyCount - 1L;
            object obj = lo > hi ? (object)new LinearIndex.relocations(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocations()) : (object)new LinearIndex.relocations(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocations());
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >)SeqModule.Zip <long, long>((IEnumerable <M0>)SeqModule.Map <long, long>((Func <M0, M1>)relocations5178, (IEnumerable <M0>)obj), SeqModule.Map <Tuple <TNewKey, long>, long>((Func <M0, M1>) new LinearIndex.relocations <TNewKey>(), (IEnumerable <M0>)array));

            return(new Tuple <IIndex <TNewKey>, VectorConstruction>((IIndex <TNewKey>)linearIndex, VectorConstruction.NewRelocate(vector, (long)array.Length, tuples)));
        }