Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
        /// <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);
        }
Beispiel #6
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);
        }