コード例 #1
0
        //
        // IEnumerable
        //

        private EntryRankMap <KeyType, ValueType> Convert(EntryMultiRankMap <KeyType, ValueType> entry)
        {
            return(new EntryRankMap <KeyType, ValueType>(
                       entry.Key,
                       entry.Value,
                       new SetValueWrapper <ValueType>(entry),
                       ((IGetEnumeratorSetValueInfo <ValueType>)entry).Version,
                       entry.Rank));
        }
コード例 #2
0
            public void Reset()
            {
                this.mapVersion        = map.version;
                this.enumeratorVersion = unchecked (this.enumeratorVersion + 1);

                current = new EntryMultiRankMap <KeyType, ValueType>();

                if (forward)
                {
                    index = -1;
                    if (startKeyed)
                    {
                        while ((index + 1 < map.items.Count) && (0 < Comparer <KeyType> .Default.Compare(startKey, map.items[index + 1].key)))
                        {
                            index++;
                        }
                        if ((index >= 0) && (index < map.items.Count) && (0 == Comparer <KeyType> .Default.Compare(startKey, map.items[index].key)))
                        {
                            index--;
                        }
                    }
                }
                else
                {
                    index = map.items.Count;
                    if (startKeyed)
                    {
                        while ((index - 1 >= 0) && (0 > Comparer <KeyType> .Default.Compare(startKey, map.items[index - 1].key)))
                        {
                            index--;
                        }
                        if ((index >= 0) && (index < map.items.Count) && (0 == Comparer <KeyType> .Default.Compare(startKey, map.items[index].key)))
                        {
                            index++;
                        }
                    }
                }

                if ((index >= 0) && (index < map.items.Count))
                {
                    current = GetItem(index);
                }
            }
コード例 #3
0
            public bool MoveNext()
            {
                if (!robust && (mapVersion != map.version))
                {
                    throw new InvalidOperationException();
                }

                this.enumeratorVersion = unchecked (this.enumeratorVersion + 1);

                if (((index >= 0) && (index < map.Count)) && (0 != Comparer <KeyType> .Default.Compare(current.Key, map.items[index].key)))
                {
                    if (forward)
                    {
                        index = 0;
                        while ((index < map.items.Count) && (0 <= Comparer <KeyType> .Default.Compare(current.Key, map.items[index].key)))
                        {
                            index++;
                        }
                        index--;
                    }
                    else
                    {
                        index = map.items.Count - 1;
                        while ((index >= 0) && (0 >= Comparer <KeyType> .Default.Compare(current.Key, map.items[index].key)))
                        {
                            index--;
                        }
                        index++;
                    }
                }

                index   = index + (forward ? 1 : -1);
                current = new EntryMultiRankMap <KeyType, ValueType>();
                if ((index >= 0) && (index < map.Count))
                {
                    current = GetItem(index);
                    return(true);
                }
                return(false);
            }