/// <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 PFKeyValueListSorted <K, V> Merge(PFKeyValueListSorted <K, V> list) { PFKeyValueListSorted <K, V> mergedList = new PFKeyValueListSorted <K, V>(); if (list == null) { return(mergedList); } IEnumerator <KeyValuePair <K, V> > enumerator = this.GetEnumerator(); while (enumerator.MoveNext()) { // Get current key value pair stKeyValuePair <K, V> keyValuePair = new stKeyValuePair <K, V>(enumerator.Current.Key, enumerator.Current.Value); mergedList.Add(keyValuePair.Key, keyValuePair.Value); } IEnumerator <KeyValuePair <K, V> > enumList = list.GetEnumerator(); while (enumList.MoveNext()) { // Get current key value pair stKeyValuePair <K, V> keyValuePair = new stKeyValuePair <K, V>(enumList.Current.Key, enumList.Current.Value); mergedList.Add(keyValuePair.Key, keyValuePair.Value); } return(mergedList); }
/// <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); }
/// <summary> /// Merges current list with the array of lists specified in the parameter. /// </summary> /// <param name="lists">Lists to merge with.</param> /// <returns>Merged list.</returns> public PFKeyValueListSorted <K, V> Merge(PFKeyValueListSorted <K, V>[] lists) { PFKeyValueListSorted <K, V> mergedList = new PFKeyValueListSorted <K, V>(); if (lists == null) { return(mergedList); } IEnumerator <KeyValuePair <K, V> > enumerator = this.GetEnumerator(); while (enumerator.MoveNext()) { // Get current key value pair stKeyValuePair <K, V> keyValuePair = new stKeyValuePair <K, V>(enumerator.Current.Key, enumerator.Current.Value); mergedList.Add(keyValuePair.Key, keyValuePair.Value); } for (int listInx = 0; listInx < lists.Length; listInx++) { PFKeyValueListSorted <K, V> tempList = lists[listInx]; if (tempList != null) { IEnumerator <KeyValuePair <K, V> > enumTempList = tempList.GetEnumerator(); while (enumTempList.MoveNext()) { // Get current key value pair stKeyValuePair <K, V> keyValuePair = new stKeyValuePair <K, V>(enumTempList.Current.Key, enumTempList.Current.Value); mergedList.Add(keyValuePair.Key, keyValuePair.Value); } } } return(mergedList); }