/// <summary>
        /// Compares two keys that are string values.
        /// </summary>
        /// <param name="x">First key/value pair to compare.</param>
        /// <param name="y">Second key/value pair to compare.</param>
        /// <returns>Less than zero: x precedes y in the sort order.  Zero: x occurs in the same position in the sort order as y. Greater than zero: x follows y in the sort order. </returns>
        public static int CompareKeyValueListStringString(pfKeyValuePair <string, string> x, pfKeyValuePair <string, string> y)
        {
            int ret = 0;

            if (x.Key != null && y.Key != null)
            {
                ret = x.Key.CompareTo(y.Key);
            }
            else
            {
                if (x.Key != null)
                {
                    ret = 1;
                }
                else if (y.Key != null)
                {
                    ret = -1;
                }
                else
                {
                    ret = 0;
                }
            }

            return(ret);
        }
Example #2
0
        /// <summary>
        /// Searches for and returns key/value pair that has matching key.
        /// </summary>
        /// <param name="keyToFind">Key to search for.</param>
        /// <returns>Object containing key and value. Returns empty key/val object if not found.</returns>
        public pfKeyValuePair <TKey, TValue> Find(string keyToFind)
        {
            pfKeyValuePair <TKey, TValue> retval = default(pfKeyValuePair <TKey, TValue>);

            foreach (pfKeyValuePair <TKey, TValue> kvp in this)
            {
                if (kvp.Key.ToString() == keyToFind)
                {
                    retval = kvp;
                }
            }
            return(retval);
        }
Example #3
0
        /// <summary>
        /// Converts PFKeyValueListEx object to PFKeyValueListExSorted object.
        /// </summary>
        /// <param name="kvlist"></param>
        /// <returns>PFKeyValueListExSorted object.</returns>
        public static PFKeyValueListExSorted <K, V> ConvertPFKeyValueListExToSortedList(PFKeyValueListEx <K, V> kvlist)
        {
            PFKeyValueListExSorted <K, V> kvlistSorted = new PFKeyValueListExSorted <K, V>();

            kvlist.SetToBOF();
            pfKeyValuePair <K, V> pfKeyValuePair = kvlist.FirstItem;

            while (!kvlist.EOF)
            {
                kvlistSorted.Add(pfKeyValuePair.Key, pfKeyValuePair.Value);
                pfKeyValuePair = kvlist.NextItem;
            }
            return(kvlistSorted);
        }
Example #4
0
        /// <summary>
        /// Converts PFKeyValueListExSorted object to PFKeyValueListEx object.
        /// </summary>
        /// <returns>PFKeyValueListEx object.</returns>
        public PFKeyValueListEx <K, V> ConvertThisToPFKeyValueListEx()
        {
            PFKeyValueListEx <K, V> kvlist = new PFKeyValueListEx <K, V>();

            IEnumerator <KeyValuePair <K, V> > enumerator = GetEnumerator();

            while (enumerator.MoveNext())
            {
                // Get current key value pair
                pfKeyValuePair <K, V> keyValuePair = new pfKeyValuePair <K, V>(enumerator.Current.Key, enumerator.Current.Value);
                kvlist.Add(keyValuePair);
            }

            return(kvlist);
        }
Example #5
0
        /// <summary>
        /// Converts current instance of a PFKeyValueListEx object to PFListEx object.
        /// </summary>
        /// <returns>PFListEx object.</returns>
        public PFListEx <pfKeyValuePair <TKey, TValue> > ConvertThisToPFListEx()
        {
            PFListEx <pfKeyValuePair <TKey, TValue> > list = new PFListEx <pfKeyValuePair <TKey, TValue> >();
            pfKeyValuePair <TKey, TValue>             kvp  = default(pfKeyValuePair <TKey, TValue>);

            if (this.Count > 0)
            {
                this.SetToBOF();
                kvp = this.FirstItem;
                while (this.EOF == false)
                {
                    list.Add(new pfKeyValuePair <TKey, TValue>(kvp.Key, kvp.Value));
                    kvp = this.NextItem;
                }
            }

            return(list);
        }
        //properties

        //methods

        /// <summary>
        /// Compares two keys that are int values.
        /// </summary>
        /// <param name="x">First key/value pair to compare.</param>
        /// <param name="y">Second key/value pair to compare.</param>
        /// <returns>Less than zero: x precedes y in the sort order.  Zero: x occurs in the same position in the sort order as y. Greater than zero: x follows y in the sort order. </returns>
        public static int CompareKeyValueListIntString(pfKeyValuePair <int, string> x, pfKeyValuePair <int, string> y)
        {
            int ret = 0;

            if (x.Key < y.Key)
            {
                ret = -1;
            }
            else if (x.Key > y.Key)
            {
                ret = 1;
            }
            else
            {
                ret = 0;
            }

            return(ret);
        }
Example #7
0
        /// <summary>
        /// Removes the item identified by the specified key from the list.
        /// </summary>
        /// <param name="keyToRemove">Key to search for and remove.</param>
        public void Remove(string keyToRemove)
        {
            pfKeyValuePair <TKey, TValue> keyval = this.Find(keyToRemove);

            this.Remove(keyval);
        }