public static void UnmergeList <T>(this IList <T> p_list, IList <T> p_otherList) { if (p_otherList != null) { List <T> v_dummyList = new List <T>(); for (int i = 0; i < p_list.Count; i++) //foreach(T v_object in p_otherList) { T v_object = p_list[i]; if (!p_otherList.Contains(v_object)) { v_dummyList.Add(v_object); } } p_list.Clear(); for (int i = 0; i < v_dummyList.Count; i++) { try { T v_object = v_dummyList[i]; if (!EqualityExtension.IsNull(v_object)) { p_list.Add(v_object); } } catch { UnityEngine.Debug.Log("An error occurred when trying to UnmergeList"); } } } }
public static bool AddChecking <T>(this IList <T> p_list, T p_object) { bool v_sucess = false; try { if (p_list != null && !EqualityExtension.IsNull(p_object) && !p_list.Contains(p_object)) { p_list.Add(p_object); v_sucess = true; } } catch { UnityEngine.Debug.Log("An error occurred when trying to AddChecking"); } return(v_sucess); }
public static void RemoveNulls <T>(this IList <T> p_list) where T : class { if (p_list != null) { List <T> v_newList = new List <T>(); for (int i = 0; i < p_list.Count; i++) { T v_object = p_list[i]; if (!EqualityExtension.IsNull(v_object)) { v_newList.Add(v_object); } } p_list.Clear(); foreach (T v_object in v_newList) { p_list.Add(v_object); } } }
public static bool RemoveChecking <T>(this IList <T> p_list, T p_object, bool p_removeNulls = true) { bool v_sucess = false; if (p_list != null && !EqualityExtension.IsNull(p_object)) { List <T> v_newList = new List <T>(); for (int i = 0; i < p_list.Count; i++) { try { T v_object = p_list[i]; if (!p_removeNulls || !EqualityExtension.IsNull(v_object)) { if (!EqualityExtension.Equals(p_object, v_object)) { v_newList.Add(v_object); } else { v_sucess = true; } } } catch { UnityEngine.Debug.Log("An error occurred when trying to RemoveChecking"); v_sucess = true; } } p_list.Clear(); foreach (T v_object in v_newList) { p_list.Add(v_object); } } return(v_sucess); }