Ejemplo n.º 1
0
        /// <summary>
        /// Routine that concatenates two or more lists into one list.
        /// </summary>
        /// <param name="lists">List of list objects to be concatenated.</param>
        /// <returns>Concatenated list.</returns>
        public static PFKeyValueListSorted <K, V> ConcatenateLists(PFList <PFKeyValueListSorted <K, V> > lists)
        {
            PFKeyValueListSorted <K, V> concatenatedList = new PFKeyValueListSorted <K, V>();

            if (lists == null)
            {
                return(concatenatedList);
            }

            for (int listInx = 0; listInx < lists.Count; listInx++)
            {
                PFKeyValueListSorted <K, V> tempList = lists[listInx];
                if (tempList != null)
                {
                    IEnumerator <KeyValuePair <K, V> > enumerator = tempList.GetEnumerator();
                    while (enumerator.MoveNext())
                    {
                        // Get current key value pair
                        stKeyValuePair <K, V> keyValuePair = new stKeyValuePair <K, V>(enumerator.Current.Key, enumerator.Current.Value);
                        concatenatedList.Add(keyValuePair.Key, keyValuePair.Value);
                    }
                }
            }

            return(concatenatedList);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Merges current list with the list of lists specified in the parameter.
        /// </summary>
        /// <param name="lists">Lists to merge with.</param>
        /// <returns>Merged list.</returns>
        public PFKeyValueList <K, V> Merge(PFList <PFKeyValueList <K, V> > lists)
        {
            PFKeyValueList <K, V> mergedList = new PFKeyValueList <K, V>();

            if (lists == null)
            {
                return(mergedList);
            }

            foreach (stKeyValuePair <K, V> item in this)
            {
                mergedList.Add(item);
            }

            for (int listInx = 0; listInx < lists.Count; listInx++)
            {
                PFKeyValueList <K, V> tempList = lists[listInx];
                if (tempList != null)
                {
                    foreach (stKeyValuePair <K, V> item in tempList)
                    {
                        mergedList.Add(item);
                    }
                }
            }

            return(mergedList);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Produces a copy of this list in which the item order has been randomized.
        /// </summary>
        /// <returns>List containing items in random order.</returns>
        public PFList <T> Randomize()
        {
            PFList <T> randomizedList = new PFList <T>();
            PFKeyValueListSorted <int, T> sortList = new PFKeyValueListSorted <int, T>();
            RandomNumber rnd = new RandomNumber();
            int          min = 0;
            int          max = 200000000;

            for (int i = 0; i < this.Count; i++)
            {
                T   item = this[i];
                int key  = rnd.GenerateRandomNumber(min, max);
                sortList.Add(key, item);
            }

            IEnumerator <KeyValuePair <int, T> > enumerator = sortList.GetEnumerator();

            while (enumerator.MoveNext())
            {
                // Get current key value pair
                stKeyValuePair <int, T> keyValuePair = new stKeyValuePair <int, T>(enumerator.Current.Key, enumerator.Current.Value);
                randomizedList.Add(keyValuePair.Value);
            }



            return(randomizedList);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Merges current list with the list of lists specified in the parameter.
        /// </summary>
        /// <param name="lists">Lists to merge with.</param>
        /// <returns>Merged list.</returns>
        public PFList <T> Merge(PFList <PFList <T> > lists)
        {
            PFList <T> mergedList = new PFList <T>();

            if (lists == null)
            {
                return(mergedList);
            }

            foreach (T item in this)
            {
                mergedList.Add(item);
            }

            for (int listInx = 0; listInx < lists.Count; listInx++)
            {
                PFList <T> tempList = lists[listInx];
                if (tempList != null)
                {
                    foreach (T item in tempList)
                    {
                        mergedList.Add(item);
                    }
                }
            }

            return(mergedList);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Copies current list to a new list.
        /// </summary>
        /// <returns>Copy of list.</returns>
        public PFList <T> Copy()
        {
            PFList <T> newList = new PFList <T>();


            foreach (T item in this)
            {
                newList.Add(item);
            }

            return(newList);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Converts current instance of a PFKeyValueList object to PFList object.
        /// </summary>
        /// <returns>PFList object.</returns>
        public PFList <stKeyValuePair <K, V> > ConvertThisToPFList()
        {
            PFList <stKeyValuePair <K, V> > list = new PFList <stKeyValuePair <K, V> >();
            stKeyValuePair <K, V>           kvp  = default(stKeyValuePair <K, V>);

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

            return(list);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Merges current list with the list specified in the parameter.
        /// </summary>
        /// <param name="list">List to merge with.</param>
        /// <returns>Merged list.</returns>
        public PFList <T> Merge(PFList <T> list)
        {
            PFList <T> mergedList = new PFList <T>();

            if (list == null)
            {
                return(mergedList);
            }

            foreach (T item in this)
            {
                mergedList.Add(item);
            }

            foreach (T item in list)
            {
                mergedList.Add(item);
            }

            return(mergedList);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Routine that concatenates two or more lists into one list.
        /// </summary>
        /// <param name="lists">List of list objects to be concatenated.</param>
        /// <returns>Concatenated list.</returns>
        public static PFKeyValueList <K, V> ConcatenateLists(PFList <PFKeyValueList <K, V> > lists)
        {
            PFKeyValueList <K, V> concatenatedList = new PFKeyValueList <K, V>();

            if (lists == null)
            {
                return(concatenatedList);
            }

            for (int listInx = 0; listInx < lists.Count; listInx++)
            {
                PFKeyValueList <K, V> tempList = lists[listInx];
                if (tempList != null)
                {
                    foreach (stKeyValuePair <K, V> item in tempList)
                    {
                        concatenatedList.Add(item);
                    }
                }
            }

            return(concatenatedList);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Routine that concatenates two or more lists into one list.
        /// </summary>
        /// <param name="lists">List of list objects to be concatenated.</param>
        /// <returns>Concatenated list.</returns>
        public static PFList <T> ConcatenateLists(PFList <PFList <T> > lists)
        {
            PFList <T> concatenatedList = new PFList <T>();

            if (lists == null)
            {
                return(concatenatedList);
            }

            for (int listInx = 0; listInx < lists.Count; listInx++)
            {
                PFList <T> tempList = lists[listInx];
                if (tempList != null)
                {
                    foreach (T item in tempList)
                    {
                        concatenatedList.Add(item);
                    }
                }
            }

            return(concatenatedList);
        }