Exemple #1
0
        public async Task <List <int> > FindItemsStartsWithAsync(T target_key, bool defaultComparer, StringComparison stringComparison, StopIndicator stopInd)
        {
            if (typeof(T) != typeof(String))
            {
                throw new InvalidOperationException("Only string Keys may use this operation");
            }

            string target_keyStr = Convert.ToString(target_key);

            List <int> foundValues = new List <int>();

            await CheckChildrenAsync().ConfigureAwait(false);

            if (Children[NumKeysUsed] != null)
            {
                foundValues.AddRange(await Children[NumKeysUsed].FindItemsStartsWithAsync(target_key, defaultComparer, stringComparison, stopInd).ConfigureAwait(false));
            }
            if (stopInd.Stop)
            {
                return(foundValues);
            }

            for (int i = NumKeysUsed - 1; i >= 0; i--)
            {
                string keyStr = Convert.ToString(Keys[i]);

                if (defaultComparer)
                {
                    if (string.Compare(keyStr, target_keyStr) <= 0)
                    {
                        if (keyStr.StartsWith(target_keyStr))
                        {
                            foundValues.AddRange(Values[i]);
                        }
                        stopInd.Stop = true;
                        return(foundValues);
                    }
                    if (keyStr.StartsWith(target_keyStr))
                    {
                        foundValues.AddRange(Values[i]);
                    }
                }
                else
                {
                    if (string.Compare(keyStr, target_keyStr, stringComparison) <= 0)
                    {
                        if (keyStr.StartsWith(target_keyStr, stringComparison))
                        {
                            foundValues.AddRange(Values[i]);
                        }
                        stopInd.Stop = true;
                        return(foundValues);
                    }
                    if (keyStr.StartsWith(target_keyStr, stringComparison))
                    {
                        foundValues.AddRange(Values[i]);
                    }
                }
                if (Children[i] != null)
                {
                    foundValues.AddRange(await Children[i].FindItemsStartsWithAsync(target_key, defaultComparer, stringComparison, stopInd).ConfigureAwait(false));
                }
            }

            return(foundValues);
        }
Exemple #2
0
        public async Task <List <int> > FindItemsStartsWithAsync(T target_key, bool defaultComparer, StringComparison stringComparison)
        {
            StopIndicator stop = new StopIndicator();

            return(await Root.FindItemsStartsWithAsync(target_key, defaultComparer, stringComparison, stop).ConfigureAwait(false));
        }
Exemple #3
0
        public async Task <List <int> > FindItemsBiggerThanAsync(T target_key, bool includeTarget, StopIndicator stopInd)
        {
            List <int> foundValues = new List <int>();

            await CheckChildrenAsync().ConfigureAwait(false);

            if (Children[NumKeysUsed] != null)
            {
                foundValues.AddRange(await Children[NumKeysUsed].FindItemsBiggerThanAsync(target_key, includeTarget, stopInd).ConfigureAwait(false));
            }
            if (stopInd.Stop)
            {
                return(foundValues);
            }

            for (int i = NumKeysUsed - 1; i >= 0; i--)
            {
                int c = this.Compare(Keys[i], target_key);

                if (c <= 0)
                {
                    if (includeTarget && c == 0)
                    {
                        foundValues.AddRange(Values[i]);
                    }
                    stopInd.Stop = true;
                    return(foundValues);
                }
                foundValues.AddRange(Values[i]);
                if (Children[i] != null)
                {
                    foundValues.AddRange(await Children[i].FindItemsBiggerThanAsync(target_key, includeTarget, stopInd).ConfigureAwait(false));
                }
            }

            return(foundValues);
        }
Exemple #4
0
        public async Task <List <int> > FindItemsBiggerThanOrEqualAsync(T target_key)
        {
            StopIndicator stop = new StopIndicator();

            return(await Root.FindItemsBiggerThanAsync(target_key, true, stop).ConfigureAwait(false));
        }