Click here to Skip to main content
15,896,726 members
Articles / Programming Languages / C#

Squeezing More Performance from SortedList

Rate me:
Please Sign up or sign in to vote.
4.76/5 (25 votes)
10 Oct 2008CPOL7 min read 77.5K   314   31  
A SortedList implementations using a cyclic algorithm and C# IDictionary tweaks
using System;
namespace SplitArrayDictionary
{

    /// <summary>
    /// Summary description for Class1
    /// </summary>
    public class StubDictionary<TValue>
        : System.Collections.Generic.IDictionary<int, TValue>
    {
        #region IDictionary<int,TValue> Members
        TValue lastValue;
        int lastint;
        public void Add(int key, TValue value)
        {
            lastValue = value;
            lastint = key;
        }

        public bool ContainsKey(int key)
        {
            if (key == lastint) return true;
            throw new NotImplementedException();
        }

        public System.Collections.Generic.ICollection<int> Keys
        {
            get { throw new NotImplementedException(); }
        }

        public bool Remove(int key)
        {
            throw new NotImplementedException();
        }

        public bool TryGetValue(int key, out TValue value)
        {
            if (key == lastint)
            {
                value = lastValue;
                return true;
            }

            throw new NotImplementedException();
        }

        public System.Collections.Generic.ICollection<TValue> Values
        {
            get { throw new NotImplementedException(); }
        }

        public TValue this[int key]
        {
            get
            {
                if (key == lastint)
                {
                    return lastValue;
                }

                throw new NotImplementedException();
            }
            set
            {
                this.lastint = key;
                this.lastValue = value;
            }
        }

        #endregion

        #region ICollection<KeyValuePair<int,TValue>> Members

        public void Add(System.Collections.Generic.KeyValuePair<int, TValue> item)
        {
            throw new NotImplementedException();
        }

        public void Clear()
        {
            this.lastint = 0;
            this.lastValue = default(TValue);
        }

        public bool Contains(System.Collections.Generic.KeyValuePair<int, TValue> item)
        {
            throw new NotImplementedException();
        }

        public void CopyTo(System.Collections.Generic.KeyValuePair<int, TValue>[] array, int arrayIndex)
        {
            throw new NotImplementedException();
        }

        public int Count
        {
            get { return -1; }
        }

        public bool IsReadOnly
        {
            get { throw new NotImplementedException(); }
        }

        public bool Remove(System.Collections.Generic.KeyValuePair<int, TValue> item)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IEnumerable<KeyValuePair<int,TValue>> Members

        public System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<int, TValue>> GetEnumerator()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Israel Israel
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions